EDN Admin
Well-known member
Basically Im just trying to use XPath to create a namespace, but cant seem to get the path selected
the xml tree is like this
<doAPI>
<doheader>
</doheader>
<dorequest>
</dorequest>
</doAPI>
I guess my big problem is trying to select the node or nodes I want, I just not quite understanding what Im doing wrong, I tried directly typing in the path with using selectsinglenode without using xpathdocument, and implementing it as well. Any suggestions
would be great! Im not exactly sure on the namespace either, the below address is what it is stated for the URI in the xml.
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Imports System.Xml
<span style="color:Blue; Imports System.Xml.XPath
<span style="color:Blue; Imports System.Text
<span style="color:Blue; Public <span style="color:Blue; Class AuditSave
<span style="color:Blue; Dim RqPathDoc <span style="color:Blue; As XPathDocument
<span style="color:Blue; Dim RqXmlNav <span style="color:Blue; As XPathNavigator
<span style="color:Blue; Dim RqNS <span style="color:Blue; As XmlNamespaceManager
<span style="color:Blue; Dim NodeIt <span style="color:Blue; As XPathNodeIterator
<span style="color:Blue; Dim RqNode <span style="color:Blue; As XmlNode
<span style="color:Blue; Dim RqName <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim RqXML <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Public <span style="color:Blue; Sub Setup()
<span style="color:Blue; Try
RqPathDoc = <span style="color:Blue; New XPathDocument(<span style="color:#A31515; "C:/AAF2.xml")
RqXmlNav = RqPathDoc.CreateNavigator
RqNS = <span style="color:Blue; New XmlNamespaceManager(RqXmlNav.NameTable)
RqNS.AddNamespace(<span style="color:#A31515; "c", <span style="color:#A31515; "http://integration.doapi.com")
NodeIt = RqXmlNav.<span style="color:Blue; Select(<span style="color:#A31515; "doAPI/c:doheader", RqNS)
<span style="color:Blue; Catch ex <span style="color:Blue; As XPathException
System.Console.WriteLine(<span style="color:#A31515; "XMLException: " + ex.Message)
<span style="color:Blue; Catch ex <span style="color:Blue; As Exception
System.Console.WriteLine(<span style="color:#A31515; "Exception: " + ex.Message)
<span style="color:Blue; End <span style="color:Blue; Try
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; Public <span style="color:Blue; Sub Selector()
<span style="color:Blue; While NodeIt.MoveNext
System.Console.WriteLine(NodeIt.Current.Name + <span style="color:#A31515; " : " + NodeIt.Current.Value)
<span style="color:Blue; End <span style="color:Blue; While
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; End <span style="color:Blue; Class
[/code] <hr class="sig .NET noob
View the full article
the xml tree is like this
<doAPI>
<doheader>
</doheader>
<dorequest>
</dorequest>
</doAPI>
I guess my big problem is trying to select the node or nodes I want, I just not quite understanding what Im doing wrong, I tried directly typing in the path with using selectsinglenode without using xpathdocument, and implementing it as well. Any suggestions
would be great! Im not exactly sure on the namespace either, the below address is what it is stated for the URI in the xml.
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Imports System.Xml
<span style="color:Blue; Imports System.Xml.XPath
<span style="color:Blue; Imports System.Text
<span style="color:Blue; Public <span style="color:Blue; Class AuditSave
<span style="color:Blue; Dim RqPathDoc <span style="color:Blue; As XPathDocument
<span style="color:Blue; Dim RqXmlNav <span style="color:Blue; As XPathNavigator
<span style="color:Blue; Dim RqNS <span style="color:Blue; As XmlNamespaceManager
<span style="color:Blue; Dim NodeIt <span style="color:Blue; As XPathNodeIterator
<span style="color:Blue; Dim RqNode <span style="color:Blue; As XmlNode
<span style="color:Blue; Dim RqName <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim RqXML <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Public <span style="color:Blue; Sub Setup()
<span style="color:Blue; Try
RqPathDoc = <span style="color:Blue; New XPathDocument(<span style="color:#A31515; "C:/AAF2.xml")
RqXmlNav = RqPathDoc.CreateNavigator
RqNS = <span style="color:Blue; New XmlNamespaceManager(RqXmlNav.NameTable)
RqNS.AddNamespace(<span style="color:#A31515; "c", <span style="color:#A31515; "http://integration.doapi.com")
NodeIt = RqXmlNav.<span style="color:Blue; Select(<span style="color:#A31515; "doAPI/c:doheader", RqNS)
<span style="color:Blue; Catch ex <span style="color:Blue; As XPathException
System.Console.WriteLine(<span style="color:#A31515; "XMLException: " + ex.Message)
<span style="color:Blue; Catch ex <span style="color:Blue; As Exception
System.Console.WriteLine(<span style="color:#A31515; "Exception: " + ex.Message)
<span style="color:Blue; End <span style="color:Blue; Try
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; Public <span style="color:Blue; Sub Selector()
<span style="color:Blue; While NodeIt.MoveNext
System.Console.WriteLine(NodeIt.Current.Name + <span style="color:#A31515; " : " + NodeIt.Current.Value)
<span style="color:Blue; End <span style="color:Blue; While
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; End <span style="color:Blue; Class
[/code] <hr class="sig .NET noob
View the full article