Click to See Complete Forum and Search --> : XmlDataDocument class


xargon
November 21st, 2003, 05:02 PM
Hi everyone,

I have the following XML structure.

<ROOT>
<ELEMENT>
<Time>100</Time>
<MIN>500</MIN>
<MAX>500</MAX>
<RESULT>OK</RESULT>
<ERRORS>NO</ERRORS>
</ELEMENT>

<ELEMENT>
<Time>100</Time>
<RESULT>OK</RESULT>
<ERRORS>NO</ERRORS>
</ELEMENT>

Unfortunately, as you can see the guy who designed the XML did not make it consistent (all ELEMENT nodes do not have the same sub-nodes). However, I am only interested in the RESULT sub-node.

So, I use the XMLDataDocument class to step through the file.
My question is that when I step in the element node, how can I just take a look at the RESULT tag.

I tried using SelectNodes (//RESULT) and SelectSingleNode(), but it always seemed to search from the root node. I want it within the context of the present node.

Thanks for any help you can give me.

Sincerely,

Xargon

khp
November 21st, 2003, 09:08 PM
The SelectNodes function evalueates it's argument as an XPath.

//RESULT evaluates, to the nodeset containing all RESULT nodes that are decendants of the root node, in other words all the RESULT nodes in the document.

To get the RESULT node that is the child of the current node, you should write SelectNodes("RESULT")

Read this (http://www.w3.org/TR/xpath#location-paths) for futher XPath details.