|
|
Please help me out to get a particuler value from XML document.
I want ti dril down in an XML doc to search for a value.
Urgent .
sanjeev
|
|
|
|
|
See XPath[^]
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
if i have to manager hundreds (maybe even thousands)of xml files, now i wanna offer my user a search function, is efficiency a serious problem f i use SAX or DOM to search for information the user query for? should i open the file just in plain text mode?
|
|
|
|
|
How will you take values for an insert statement
To insert the table values some values from one table and some values from open xml this will carried in a Stored Procedure
Help Please
Thanx
-
|
|
|
|
|
Please Help !!!!!!
I am using an xml file as my database . But I can't do insert, update and delete ops !!!
Pls give the code .
Thanks in advance ...........
|
|
|
|
|
|
I am new to XSL and I need help.
I have the following xml:
<Documents>
<Document>
<DocId>1</DocId>
<Status>1</Status>
<Page>1</Page>
</Document>
<Document>
<DocId>1</DocId>
<Status>1</Status>
<Page>2</Page>
</Document>
<Document>
<DocId>1</DocId>
<Status>2</Status>
<Page>1</Page>
</Document>
<Document>
<DocId>2</DocId>
<Status>1</Status>
<Page>1</Page>
</Document>
<Document>
<DocId>2</DocId>
<Status>2</Status>
<Page>1</Page>
</Document>
<Document>
<DocId>2</DocId>
<Status>3</Status>
<Page>1</Page>
</Document>
<Document>
<DocId>3</DocId>
<Status>1</Status>
<Page>1</Page>
</Document>
<Document>
<DocId>3</DocId>
<Status>1</Status>
<Page>2</Page>
</Document>
<Document>
<DocId>3</DocId>
<Status>1</Status>
<Page>3</Page>
</Document>
</Documents>
I have to sort the documents with DocId and Status. I would like to transform this xml to:
<Documents>
<Document>
<DocId>1</DocId>
<Pages>
<Page>
<Status>1</Status>
<Page>1</Page>
</Page>
<Page>
<Status>1</Status>
<Page>2</Page>
</Page>
</Pages>
</Document>
<Document>
<DocId>1</DocId>
<Pages>
<Page>
<Status>2</Status>
<Page>1</Page>
</Page>
</Pages>
</Document>
<Document>
<DocId>2</DocId>
<Pages>
<Page>
<Status>1</Status>
<Page>1</Page>
</Page>
</Pages>
</Document>
<Document>
<DocId>2</DocId>
<Pages>
<Page>
<Status>2</Status>
<Page>1</Page>
</Page>
</Pages>
</Document>
<Document>
<DocId>2</DocId>
<Pages>
<Page>
<Status>3</Status>
<Page>1</Page>
</Page>
</Pages>
</Document>
<Document>
<DocId>3</DocId>
<Pages>
<Page>
<Status>1</Status>
<Page>1</Page>
</Page>
<Page>
<Status>1</Status>
<Page>2</Page>
</Page>
<Page>
<Status>1</Status>
<Page>3</Page>
</Page>
</Pages>
</Document>
</Documents>
Please help!!!
Subbakka
|
|
|
|
|
I am new to XSL and I need help.
I have the following xml:
<documents>
<document>
<docid>1
<status>1
<page>1
<document>
<docid>1
<status>1
<page>2
<document>
<docid>1
<status>2
<page>1
<document>
<docid>2
<status>1
<page>1
<document>
<docid>2
<status>2
<page>1
<document>
<docid>2
<status>3
<page>1
<document>
<docid>3
<status>1
<page>1
<document>
<docid>3
<status>1
<page>2
<document>
<docid>3
<status>1
<page>3
I have to sort the documents with DocId and Status. I would like to transform this xml to:
<documents>
<document>
<docid>1
<pages>
<page>
<status>1
<page>1
<page>
<status>1
<page>2
<document>
<docid>1
<pages>
<page>
<status>2
<page>1
<document>
<docid>2
<pages>
<page>
<status>1
<page>1
<document>
<docid>2
<pages>
<page>
<status>2
<page>1
<document>
<docid>2
<pages>
<page>
<status>3
<page>1
<document>
<docid>3
<pages>
<page>
<status>1
<page>1
<page>
<status>1
<page>2
<page>
<status>1
<page>3
Please help!!!
Subbakka
|
|
|
|
|
You can modify the post rather than start a whole new one. This keeps the forum clean and free from clutter.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
<xml xmlns:x="urn:schemas-microsoft-com:office:excel">
<x:PivotTable>
<x:OWCVersion>11.0.0.6555</x:OWCVersion>
<x:NoDisplayAlerts/>
<x:DisplayScreenTips/>
<x:CubeProvider>msolap.2</x:CubeProvider>
<x:CacheDetails/>
<x:ConnectionString>Provider=MSOLAP.2;Integrated Security=SSPI;Persist Security Info=False;Location=C:\sales.cub;Initial Catalog=Sales;Client Cache Size=25;Auto Synch Period=10000;Log File=C:\log.txt</x:ConnectionString>
<x:DataMember>Sales</x:DataMember>
<x:Name>City Comparison of Drink Sales</x:Name>
<x:PivotField>
<x:Name>Country</x:Name>
<x:SourceName>[Customers].[Country]</x:SourceName>
<x:FilterCaption>Customers</x:FilterCaption>
<x:Orientation>Row</x:Orientation>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
<x:AutoSortOrder>Descending</x:AutoSortOrder>
<x:Expanded/>
</x:PivotField>
<x:PivotField>
<x:Name>State Province</x:Name>
<x:SourceName>[Customers].[State Province]</x:SourceName>
<x:Orientation>Row</x:Orientation>
<x:Position>2</x:Position>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>City</x:Name>
<x:SourceName>[Customers].[City]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Name</x:Name>
<x:SourceName>[Customers].[Name]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Gender</x:Name>
<x:SourceName>[Gender].[Gender]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Product Family</x:Name>
<x:SourceName>[Product].[Product Family]</x:SourceName>
<x:FilterCaption>Product</x:FilterCaption>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Product Department</x:Name>
<x:SourceName>[Product].[Product Department]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Product Category</x:Name>
<x:SourceName>[Product].[Product Category]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Product Subcategory</x:Name>
<x:SourceName>[Product].[Product Subcategory]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Brand Name</x:Name>
<x:SourceName>[Product].[Brand Name]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Product Name</x:Name>
<x:SourceName>[Product].[Product Name]</x:SourceName>
<x:CompareOrderedMembersBy>UniqueName</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Year</x:Name>
<x:SourceName>[Time].[Year]</x:SourceName>
<x:FilterCaption>Time</x:FilterCaption>
<x:Orientation>Column</x:Orientation>
<x:CompareOrderedMembersBy>Name</x:CompareOrderedMembersBy>
<x:Expanded/>
</x:PivotField>
<x:PivotField>
<x:Name>Quarter</x:Name>
<x:SourceName>[Time].[Quarter]</x:SourceName>
<x:CompareOrderedMembersBy>Name</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Month</x:Name>
<x:SourceName>[Time].[Month]</x:SourceName>
<x:CompareOrderedMembersBy>Name</x:CompareOrderedMembersBy>
</x:PivotField>
<x:PivotField>
<x:Name>Profit</x:Name>
<x:SourceName>[Measures].[Profit]</x:SourceName>
<x:SourceHierarchy>[Measures].[Profit]</x:SourceHierarchy>
</x:PivotField>
<x:PivotField>
<x:Name>Store Sales</x:Name>
<x:SourceName>[Measures].[Store Sales]</x:SourceName>
<x:SourceHierarchy>[Measures].[Store Sales]</x:SourceHierarchy>
</x:PivotField>
<x:PivotField>
<x:Name>Data</x:Name>
<x:Orientation>Column</x:Orientation>
<x:Position>-1</x:Position>
<x:DataField/>
</x:PivotField>
<x:PivotField>
<x:Name>Profit</x:Name>
<x:TotalNumber>0</x:TotalNumber>
<x:Orientation>Data</x:Orientation>
<x:Position>1</x:Position>
<x:ParentField>[Measures].[Profit]</x:ParentField>
</x:PivotField>
<x:PivotField>
<x:Name>Store Sales</x:Name>
<x:TotalNumber>4</x:TotalNumber>
<x:Orientation>Data</x:Orientation>
<x:Position>2</x:Position>
<x:ParentField>[Measures].[Store Sales]</x:ParentField>
</x:PivotField>
<x:PLTotal>
<x:Name>Sales Average</x:Name>
<x:TotalNumber>1</x:TotalNumber>
</x:PLTotal>
<x:PLTotal>
<x:Name>Sales Count</x:Name>
<x:TotalNumber>2</x:TotalNumber>
</x:PLTotal>
<x:PLTotal>
<x:Name>Store Cost</x:Name>
<x:TotalNumber>3</x:TotalNumber>
</x:PLTotal>
<x:PLTotal>
<x:Name>Store Sales Net</x:Name>
<x:TotalNumber>5</x:TotalNumber>
</x:PLTotal>
<x:PLTotal>
<x:Name>Unit Sales</x:Name>
<x:TotalNumber>6</x:TotalNumber>
</x:PLTotal>
<x:PivotView>
<x:IsNotFiltered/>
<x:Label>
<x:Caption>City Comparison of Drink Sales</x:Caption>
</x:Label>
</x:PivotView>
<x:PivotAxis>
<x:Orientation>Row</x:Orientation>
<x:DisplayEmptyMembers/>
</x:PivotAxis>
<x:PivotAxis>
<x:Orientation>Column</x:Orientation>
<x:DisplayEmptyMembers/>
</x:PivotAxis>
</x:PivotTable>
</xml>
This is my XML file and i m not getting the root element of this XML.I have to transform this file in to the XSL file and then shown on to the page using javascript.The Basic problem is that i m not getting the Root Element of this XML file.Please anybody help me as soon as possible.This XML is generated by the datasource of PivotTable i.e the OLAP tool.Actually i have to get the PivotField's Child element SourceName through which i again have to make an MDX Query.
Nitin Kale
-- modified at 4:26 Thursday 18th May, 2006
|
|
|
|
|
I want to get a hyperlink to display in an .aspx page the content of which
comes from loading an Xml document.
Cheers.
The XML document looks like this :
<FAQ>
<Answer>Go to the <a href=www.google.com>TEST</a> section to view details.</Answer>
</FAQ>
|
|
|
|
|
JoJuPi01 wrote: <answer>Go to the TEST section to view details.
you have to Write DTD file for same!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
I have to parse an xml file in VC6 , Can I use the IXMLDOMDocumentPtr object in my application, if so then wat headers and imports i have to add to my project? I know tha IXMLDOMDocumentPtr can easily be used in VC.Net but dont know if it is valid in VC6 .
Cyber Friend
|
|
|
|
|
Yes:
#include <comdef.h>
#import <msxml4.dll> // I am using version 4. You might have something else installed
...
using MSXML2::IXMLDOMDocument2Ptr;
using MSXML2::DOMDocument40;
...
CoInitialize(NULL);
IXMLDOMDocument2Ptr pXMLDom;
HRESULT hr = pXMLDom.CreateInstance(__uuidof(DOMDocument40));
if (FAILED(hr))
{
...
}
...
pXMLDom.Release();
CoUninitialize();
|
|
|
|
|
I need to export xml data to excel.This should be done using servlets.Somebody help me .
vidya
|
|
|
|
|
Hello, i would like to know how to sort an xml file. here is the xml file i have:
<books>
<book>
<title>Advanced XML
<publisher>Lucerne Publishing
<book>
<title>Learn XML Today
<publisher>MSPress
<book>
<title>XML for Gurus
<publisher>Lucerne Publishing
<book>
<title>Developing XML solutions
<publisher>MSPress
I don't have any template or style file.
I want to display a sorted information inside a listbox using C#:
Advanced XML, Lucerne Publishing
XML for Gurus, Lucerne Publishing
Developing XML solutions, MSPress
Learn XML Today, MSPress
I assume that we want to sort by the publisher first and then by the title.
Any suggestion will be great.
|
|
|
|
|
Sorry it didn't show the tags
<?xml version='1.0'?>
<Books>
<Book>
<Title>Advanced XML</Title>
<Publisher>Lucerne Publishing</Publisher>
</Book>
<Book>
<Title>Learn XML Today</Title>
<Publisher>MSPress</Publisher>
</Book>
<Book>
<Title>XML for Gurus</Title>
<Publisher>Lucerne Publishing</Publisher>
</Book>
<Book>
<Title>Developing XML solutions</Title>
<Publisher>MSPress</Publisher>
</Book>
</Books>
|
|
|
|
|
I did this in a hurry. The XSLT coding sample seems more complicated since I used strings for the xml and xslt.
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
namespace SortXml
{
class Program
{
static void Main(string[] args)
{
string xml =
"<?xml version='1.0'?>" +
"<Books>" +
"<Book>" +
"<Title>Advanced XML</Title>" +
"<Publisher>Lucerne Publishing</Publisher>" +
"</Book>" +
"<Book>" +
"<Title>Learn XML Today</Title>" +
"<Publisher>MSPress</Publisher>" +
"</Book>" +
"<Book>" +
"<Title>XML for Gurus</Title>" +
"<Publisher>Lucerne Publishing</Publisher>" +
"</Book>" +
"<Book>" +
"<Title>Developing XML solutions</Title>" +
"<Publisher>MSPress</Publisher>" +
"</Book>" +
"</Books>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNodeList nodes =
doc.DocumentElement.SelectNodes(
"/Books/Book/Title/child::text()");
// Sorting using an array.
if (nodes.Count > 0)
{
string[] titles = new string[nodes.Count];
int i = 0;
foreach (XmlNode node in nodes)
{
titles[i++] = node.Value;
}
Array.Sort(titles);
foreach (string title in titles)
{
Console.WriteLine(title);
}
}
Console.WriteLine();
// Sorting using XSLT
string xslt =
"<xsl:stylesheet version='1.0' " +
"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" +
"<xsl:template match='/ | @* | node()'>" +
"<xsl:copy>" +
"<xsl:apply-templates select='@* | node()'>" +
"<xsl:sort select='Title'/>" +
"</xsl:apply-templates>" +
"</xsl:copy>" +
"</xsl:template>" +
"</xsl:stylesheet>";
XslCompiledTransform xct = new XslCompiledTransform();
StringReader strXslStr = new StringReader(xslt);
XmlReader rdrXsl = XmlReader.Create(strXslStr);
xct.Load(rdrXsl);
rdrXsl.Close();
strXslStr.Close();
XPathNavigator xpnav = doc.CreateNavigator();
StringBuilder sbXml = new StringBuilder();
XmlWriter sortedXml = XmlWriter.Create(sbXml);
xct.Transform(xpnav, sortedXml);
doc.LoadXml(sbXml.ToString());
sortedXml.Close();
nodes = doc.DocumentElement.SelectNodes(
"/Books/Book/Title/child::text()");
if (nodes.Count > 0)
{
foreach (XmlNode node in nodes)
{
Console.WriteLine(node.Value);
}
}
}
}
}
-- modified at 23:47 Tuesday 16th May, 2006
|
|
|
|
|
Hi George,
is XSLT a separate file or a new C# class.
I was wondering how can we create a XSL or XSLT file from an XML?
Sorry Im new to XML programming.
Donkaiser
|
|
|
|
|
XSTL (XSL) source code is really a XML (text) file:
<?xml version='1.0'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match='/ | @* | node()'>
<xsl:copy>
<xsl:apply-templates select='@* | node()'>
<xsl:sort select='Title'/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The elements with the "xsl" namespace are used to manipulate, sort, and filter XML data. C# (my example uses the .Net 2.0 Framework) has classes that can compile and run XSLT source code to process XML data.
Go to http://www.w3.org/Style/XSL/[^] for more information. Also, search your Visual Studio Documentation on how to use it with C#.
-- modified at 10:34 Wednesday 17th May, 2006
|
|
|
|
|
Thank George,
I know how to create a xsl now. but how can we bind it to the existing xml file?
Donkaiser
|
|
|
|
|
I am assuming you are using C# 2.0. My example above shows you how. Anyway, I will make a commented snippet:
// Sorting using XSLT
string xslt =
"<xsl:stylesheet version='1.0' " +
"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" +
"<xsl:template match='/ | @* | node()'>" +
"<xsl:copy>" +
"<xsl:apply-templates select='@* | node()'>" +
"<xsl:sort select='Title'/>" +
"</xsl:apply-templates>" +
"</xsl:copy>" +
"</xsl:template>" +
"</xsl:stylesheet>";
XslCompiledTransform xct = new XslCompiledTransform(); // The XSLT Compiler/Transformer
StringReader strXslStr = new StringReader(xslt); // Create a XmlReader stream using a string source (the string = XSLT)
XmlReader rdrXsl = XmlReader.Create(strXslStr);
xct.Load(rdrXsl); // the XSLT Transformer reads the XSLT and compiles it.
rdrXsl.Close(); // Closing Streams
strXslStr.Close();
XPathNavigator xpnav = doc.CreateNavigator(); // Create the XPathNavigator from a XmlDocument Object
StringBuilder sbXml = new StringBuilder(); // Create a XmlWriter stream with a StringBuilder output buffer
XmlWriter sortedXml = XmlWriter.Create(sbXml);
xct.Transform(xpnav, sortedXml); // The actual transformation of the XML using the above XSLT document
doc.LoadXml(sbXml.ToString()); // The Transformed XML output is in the StringBuilder object.
sortedXml.Close(); // Close the stream.
|
|
|
|
|
Sroun Ngo wrote: Any suggestion will be great.
ok, then....
Sroun Ngo wrote: I assume
Don't make assumptions.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|