Re: Using XPath Against A Node
- From: Martin Honnen <mahotrash@xxxxxxxx>
- Date: Wed, 06 Dec 2006 18:53:27 +0100
Derek Hart wrote:
So if I pass a node to a function, can I treat the top-most element as the top parent? That is my question. Or is the entire xml document sent with it. I do not want it to be possible to look at the whole document in the function. I just want to pass in a specific node. Is it possible?
In the DOM an XmlNode always has an OwnerDocument property set to the document that created the node. A node cannot exist without its owning document as you can only create nodes with the factory methods of the XmlDocument instance. A node does not need to have a ParentNode property being non null however.
In terms of the XPath implementation with SelectSingleNode and SelectNodes if the node is not inserted in the owning document then it looks like the XPath / evaluates to the node itself. Thus if you do e.g.
Dim Xml_Doc as XmlDocument = New XmlDocument()
Dim SomeElement as XmlElement = Xml_Doc.CreateElement("whatever")
and pass that node around without inserting it into the document then the node in terms of XPath and SelectNodes/SelectSingleNode does not expose the document.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
.
- References:
- Using XPath Against A Node
- From: Derek Hart
- Re: Using XPath Against A Node
- From: FishingScout
- Re: Using XPath Against A Node
- From: Derek Hart
- Using XPath Against A Node
- Prev by Date: Boostraper para SQL Express 2005
- Next by Date: Re: OLEDBCommand vs. SQLCommand
- Previous by thread: Re: Using XPath Against A Node
- Next by thread: Re: Using XPath Against A Node
- Index(es):
Relevant Pages
|