B
bbb
Hi,
I need to get some values from the OAGIS xml( giving valid part for
simlicity):
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <ShowInvoice environment="" lang="en-US" revision="8.0"
xmlns="http://www.openapplications.org/oagis" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
www.openapplications.org/oagis C:\OAGIS8.0\OAGIS\BODs
\ShowInvoice.xsd">
- <ApplicationArea>
- <Sender>
<LogicalId>LID</LogicalId>
<Confirmation>Always</Confirmation>
<AuthorizationId>AID</AuthorizationId>
</Sender>
<CreationDateTime>2007-01-05T17:09:56Z</CreationDateTime>
<BODId>12345678</BODId>
<UserArea />
</ApplicationArea>
- <DataArea>
<Show confirm="Always" />
- <Invoice>
- <Header>
- <DocumentIds>
- <DocumentId>
<Id>123456789</Id>
</DocumentId>
</DocumentIds>
<Note>Note</Note>
<TotalAmount currency="USD">10000.0</TotalAmount>
<PaymentTerms />
<Type>Debit</Type>
<PaymentMethod>Other</PaymentMethod>
- <Tax>
<TaxAmount currency="USD">0.0</TaxAmount>
</Tax>
</Header>
</Invoice>
</DataArea>
</ShowInvoice>
Here the code I'm using :
string xpathExpression = "//Header/Note";
XmlDocument document = new XmlDocument();
document.Load(filename);
XmlNamespaceManager ns = new
XmlNamespaceManager(document.NameTable);
ns.AddNamespace("", "http://www.openapplications.org/
oagis");
ns.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-
instance");
XmlNode node = document.SelectSingleNode(xpathExpression,
ns);
if (node != null)
{ string note = node.InnerXml.ToString(); }
Everything works( even without using XmlNamespaceManager ) If i
removed all xmlns entries(xmlns="http://www.openapplications.org/
oagis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openapplications.org/oagis C:
\OAGIS8.0\OAGIS\BODs\ShowInvoice.xsd") from the ShowInvoice root.
But with those entries node is always null. I've tried all the
combination of AddNamespace - nothing worked.
Please help.
Thanks in advance.
I need to get some values from the OAGIS xml( giving valid part for
simlicity):
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <ShowInvoice environment="" lang="en-US" revision="8.0"
xmlns="http://www.openapplications.org/oagis" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
www.openapplications.org/oagis C:\OAGIS8.0\OAGIS\BODs
\ShowInvoice.xsd">
- <ApplicationArea>
- <Sender>
<LogicalId>LID</LogicalId>
<Confirmation>Always</Confirmation>
<AuthorizationId>AID</AuthorizationId>
</Sender>
<CreationDateTime>2007-01-05T17:09:56Z</CreationDateTime>
<BODId>12345678</BODId>
<UserArea />
</ApplicationArea>
- <DataArea>
<Show confirm="Always" />
- <Invoice>
- <Header>
- <DocumentIds>
- <DocumentId>
<Id>123456789</Id>
</DocumentId>
</DocumentIds>
<Note>Note</Note>
<TotalAmount currency="USD">10000.0</TotalAmount>
<PaymentTerms />
<Type>Debit</Type>
<PaymentMethod>Other</PaymentMethod>
- <Tax>
<TaxAmount currency="USD">0.0</TaxAmount>
</Tax>
</Header>
</Invoice>
</DataArea>
</ShowInvoice>
Here the code I'm using :
string xpathExpression = "//Header/Note";
XmlDocument document = new XmlDocument();
document.Load(filename);
XmlNamespaceManager ns = new
XmlNamespaceManager(document.NameTable);
ns.AddNamespace("", "http://www.openapplications.org/
oagis");
ns.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-
instance");
XmlNode node = document.SelectSingleNode(xpathExpression,
ns);
if (node != null)
{ string note = node.InnerXml.ToString(); }
Everything works( even without using XmlNamespaceManager ) If i
removed all xmlns entries(xmlns="http://www.openapplications.org/
oagis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openapplications.org/oagis C:
\OAGIS8.0\OAGIS\BODs\ShowInvoice.xsd") from the ShowInvoice root.
But with those entries node is always null. I've tried all the
combination of AddNamespace - nothing worked.
Please help.
Thanks in advance.