Re: Using XPath Against A Node
- From: "FishingScout" <fishingscout@xxxxxxxxxxx>
- Date: 6 Dec 2006 10:01:03 -0800
If there is some reason you don't want a method to access the document
from a node, it is possible to create a new xml document with only that
node and its descendants and pass it to a method. If the method
modifies the node you will need to do some work to replace the original
node with the modified node.
I don't know of any way to "protect" ancestor nodes within the DOM.
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?
Derek
"FishingScout" <fishingscout@xxxxxxxxxxx> wrote in message
news:1165383052.131851.94120@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Derek,
I am not sure what you meant by: "and I could assume that the top part
of that node was the new parent."
Using "/" will search the document root node immediate descendants.
Using "./" will search the context node immediate descendants.
Using "// will search anywhere in the entire document.
Using ".//" will search anywhere in the context node descendants.
Similarly, you could use "descendant::".
If you know the absolute path of the data you are looking for, you can
simply skip the "//" or the "/". For example, if "Price" were an
attribute of "Model", which is an immediate descendant of Vehicles, you
could query for the price of a model using "Model/@Price". If you are
a high paid developer you could search for a specific model using
"Model[.='Cadillac']/@Price". You don't need to use ".//Model/@Price"
or "descendant::Model/@Price".
I don't know if this was helpful but .... I don't drive a Cadillac.
Derek Hart wrote:
I bring in an xml file into vb.net by using xmlDoc.LoadXml(XMLString) - I
run xpath statements against the xml file to grab data from it, so I use,
as
an example, //Vehicles/Vehicles/@make to get the make of the car. But
then
I pass a specific node from xmlDoc into another function, not the whole
xmlDoc, just a node from it. And if I run an xpath against it, I have to
use .// (has a period at the beginning) so it does not grab info from the
parent. So I would have to use .//Vehicles/Vehicles/@make so it
references
the current node. I would think that if I passed a node to a vb.net
function, I could simply use an xpath statement that would work off the
passed in node, and I could assume that the top part of that node was the
new parent. Is there a way to pass a node like this?
Derek
.
- Follow-Ups:
- Re: Using XPath Against A Node
- From: Derek Hart
- Re: Using XPath Against A Node
- 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: Re: OLEDBCommand vs. SQLCommand
- Next by Date: Re: FSO equivalent in VB.net
- Previous by thread: Re: Using XPath Against A Node
- Next by thread: Re: Using XPath Against A Node
- Index(es):
Relevant Pages
|
Loading