Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XPATH Query by Attribute

Status
Not open for further replies.

tlhawkins

Programmer
Dec 28, 2000
797
US
Hey all,

I'm fairly new to XML and I've run into a problem that I can't find and answer for on the web (I'm hope it's not impossible).

I have an XML file that looks something like:
Code:
<Root id=&quot;1&quot;>
  <FOLDER id=&quot;1&quot;>
    <DOCUMENT id=&quot;1&quot;/>
  </FOLDER>
  <FOLDER id=&quot;2&quot;>
    <DOCUMENT id=&quot;2&quot;/>
    <DOCUMENT id=&quot;3&quot;/>
  </FOLDER>
  <FOLDER id=&quot;3&quot;>
    <DOCUMENT id=&quot;4&quot;/>
  </FOLDER>
</Root>

I'm using VBSCRIPT with MSXML2.FreeThreadedDOMDocument.3.0

I need to select the folder with the id=1 with an XPATH query.

I've been using:

set Nodes = xmlDoc.selectNodes(&quot;//FOLDER&quot;)

and then looping through the Nodes looking for the correct ID, but it is giving me grief. It would be great if I could just select the correct folder with:

selectSingleNode(XPATH)

If someone could help I would appreciate it



 
Silly me.
I figured it out right after posting.
For anyone else here is the answer:

root.selectSingleNode(&quot;//FOLDER[@ID='1']&quot;)




Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top