Re: System.XML.XPath XPathDocument load question

Tech-Archive recommends: Speed Up your PC by fixing your registry





Tony Girgenti wrote:


I'm getting an XML document this way:
Dim node As XmlNode = proxy.RetrieveArchivedTrips(strDate, endDate)
Dim doc As XmlDocument = node.OwnerDocument
doc.AppendChild(node)

At this point "doc" contains the XML document that i am using. However, i'm reading Beginning VB.NET XML. In all of the examples to use XPathDocument, it always refers to a file on disk such as:
Dim xpDoc As XPathDocument = New XPathDocument("..\\CaseStudy.xml")

In the above statement, how do i get my "doc" to be used in place of "..\\CaseStudy.xml" ?

XmlDocument and XPathDocument are two different classes but both implement IXPathNavigable.
So usually all you do with xpDoc is e.g.
Dim navigator As XPathNavigator = xpDoc.CreateNavigator();
where you could simply do
Dim navigator As XPathNavigator = doc.CreateNavigator();
to get an XPathNavigator over your XmlDocument instance. The use of that navigator is the same then, whether you created it from an XPathDocument or XmlDocument instance.
Does that help? Or why exactly do you want/need to have an XPathDocument when you already have an XmlDocument?


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
.



Relevant Pages

  • Re: Using XPath Against A Node
    ... made to the XML DOM passed into the DoSomeXmlProcessing, ... Dim WholeXmlDocument As New XmlDocument ... If Not VehicleNode Is Nothing Then ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Xml error: Namespace Manager or Xslt context needed
    ... "XML newbie: Urgent pls help!" ... ' Instantiate an XmlDocument object to avoid NullReference ... Dim xmlDoc As XmlDocument ... Dim strm As Stream = HttpWResponse.GetResponseStream ...
    (microsoft.public.dotnet.xml)
  • Re: Xml error: Namespace Manager or Xslt context needed
    ... Thanks for yur response. ... Private Function SendXmlRequest(ByRef xml As String) ... ' Instantiate an XmlDocument object to avoid NullReference ... Dim xmlDoc As XmlDocument ...
    (microsoft.public.dotnet.xml)
  • RE: using myXslDoc.Transform
    ... One potential option for dynamically loading an XmlDocument from the ... retrieved as a string. ... Retrieve the XML content from the database ... Dim strXml As String ...
    (microsoft.public.dotnet.xml)
  • Re: Xml error: Namespace Manager or Xslt context needed
    ... Can't parse login information. ... Private Function SendXmlRequest(ByRef xml As String) ... ' Instantiate an XmlDocument object to avoid NullReference ... Dim xmlDoc As XmlDocument ...
    (microsoft.public.dotnet.xml)