klornpallier
Technical User
Hi,
I have the xml below which I am reading using XML Document. My code also below works fine if I take the namespace out of the xml but I cannot seem to get the reader right with the NameSpace. Advice would be appreciated.
<?xml version="1.0" encoding="UTF-8" ?>
- <iPOSImports xmlns=" xmlns:xsi="- <Kofax>
- <Invoices>
- <Invoice>
<Company>SHA</Company>
<SupplierAccntCode>8SUPP</SupplierAccntCode>
<SupplierInvoiceNo>ABC123456789</SupplierInvoiceNo>
<InvoiceDate>2010-01-01</InvoiceDate>
<TotalValue>117.50</TotalValue>
<OrderNo>123456789</OrderNo>
<Barcode>ABCDEF1234567890</Barcode>
<DocumentType>I</DocumentType>
</Invoice>
</Invoices>
</Kofax>
</iPOSImports>
---------------------
My Code
' Declare a variable named InvoiceXmlDocument of type XmlDocument.
Dim InvoiceXmlDocument As XmlDocument
' Instantiate a new XmlDocument object assigning it to the 'InvoiceXmlDocument variable.
InvoiceXmlDocument = New XmlDocument
' Call the OrderXmlDocument object's Load method
' passing it the file path to a .xml file that defines order information.
InvoiceXmlDocument.Load(FullName)
' Declare a variable named theXPathNavigator of type XPathNavigator.
Dim theXPathNavigator As XPathNavigator
' Call the OrderXmlDocument object's CreateNavigator method
' assigning the resulting XPathNavigator object to the 'theXPathNavigator' variable.
theXPathNavigator = InvoiceXmlDocument.CreateNavigator
' Declare a variable named theXPathExpression of type XPathExpression.
Dim theXPathExpression As XPathExpression
' Call theXPathNavigator object's Compile method passing it a query string;
' assign the resulting XPathPression object to the 'theXPathExpression' variable.
theXPathExpression = theXPathNavigator.Compile("//Kofax/Invoices/Invoice/Company")
' Declare a variable named nodes of type XPathNodeIterator.
Dim nodeHead As XPathNodeIterator
' Call theXPathNavigator's Select method passing it theXPathExpression;
' assign the resulting XPathNodeIterator object to the 'nodes' variable.
nodeHead = theXPathNavigator.Select(theXPathExpression)
' Iterate through the Item nodes writing out each items details,
While (nodeHead.MoveNext())
Console.Write("Company: " & nodeHead.Current.Value.ToString & Environment.NewLine)
Company = nodeHead.Current.Value.ToString
I have the xml below which I am reading using XML Document. My code also below works fine if I take the namespace out of the xml but I cannot seem to get the reader right with the NameSpace. Advice would be appreciated.
<?xml version="1.0" encoding="UTF-8" ?>
- <iPOSImports xmlns=" xmlns:xsi="- <Kofax>
- <Invoices>
- <Invoice>
<Company>SHA</Company>
<SupplierAccntCode>8SUPP</SupplierAccntCode>
<SupplierInvoiceNo>ABC123456789</SupplierInvoiceNo>
<InvoiceDate>2010-01-01</InvoiceDate>
<TotalValue>117.50</TotalValue>
<OrderNo>123456789</OrderNo>
<Barcode>ABCDEF1234567890</Barcode>
<DocumentType>I</DocumentType>
</Invoice>
</Invoices>
</Kofax>
</iPOSImports>
---------------------
My Code
' Declare a variable named InvoiceXmlDocument of type XmlDocument.
Dim InvoiceXmlDocument As XmlDocument
' Instantiate a new XmlDocument object assigning it to the 'InvoiceXmlDocument variable.
InvoiceXmlDocument = New XmlDocument
' Call the OrderXmlDocument object's Load method
' passing it the file path to a .xml file that defines order information.
InvoiceXmlDocument.Load(FullName)
' Declare a variable named theXPathNavigator of type XPathNavigator.
Dim theXPathNavigator As XPathNavigator
' Call the OrderXmlDocument object's CreateNavigator method
' assigning the resulting XPathNavigator object to the 'theXPathNavigator' variable.
theXPathNavigator = InvoiceXmlDocument.CreateNavigator
' Declare a variable named theXPathExpression of type XPathExpression.
Dim theXPathExpression As XPathExpression
' Call theXPathNavigator object's Compile method passing it a query string;
' assign the resulting XPathPression object to the 'theXPathExpression' variable.
theXPathExpression = theXPathNavigator.Compile("//Kofax/Invoices/Invoice/Company")
' Declare a variable named nodes of type XPathNodeIterator.
Dim nodeHead As XPathNodeIterator
' Call theXPathNavigator's Select method passing it theXPathExpression;
' assign the resulting XPathNodeIterator object to the 'nodes' variable.
nodeHead = theXPathNavigator.Select(theXPathExpression)
' Iterate through the Item nodes writing out each items details,
While (nodeHead.MoveNext())
Console.Write("Company: " & nodeHead.Current.Value.ToString & Environment.NewLine)
Company = nodeHead.Current.Value.ToString