Re: Using XPath Against A Node



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

.



Relevant Pages

  • Re: Using XPath Against A Node
    ... of that node was the new parent." ... Using "/" will search the document root node immediate descendants. ... run xpath statements against the xml file to grab data from it, so I use, ... I pass a specific node from xmlDoc into another function, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Using XPath Against A Node
    ... Or is the entire xml document sent with ... of that node was the new parent." ... Using "/" will search the document root node immediate descendants. ... run xpath statements against the xml file to grab data from it, so I use, ...
    (microsoft.public.dotnet.languages.vb)