This is a piece of my XML document:
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<mfVictor>
<decal>
<company>Victor</company>
<title>Wood Horn with Blue Background</title>
<image>
<url>victor01.jpg</url>
<width>60</width>
<height>60</height>
<name>Wood Horn Blue Background</name>
<link></link>
</image>
<price>$15.00</price>
<instock>In Stock</instock>
<notes>none</notes>
</decal>
</mfVictor>
</catalog>
I have a function that generates a list of the text from each “title” element. So then, onmousedown of each list item I want to navigate to the “decal” and access all of its children. So far I have this:
//decal[contains(.,\'"+itemName+"\')]
where the itemName is this.innerHTML passed to the function. It looks like the decal is accessed because in the console.log I can see an XMLobject with a length of 1. But I can’t figure out how to access either the children of “decal” or the siblings of “title”.
Thanks for reading.
If you need to select a decal based on his title I would prefer the following xpaths:
to select a sibling of the title of the decal you selected you can use
If you want all the children of the decal you select you can use (maybe you need this)
or better, if you have the complete title
With the square bracket you instruct the parser to walk the xml tree to make a selection based on the condition you specify but without changing the context node. Think to the square brackets as a rubber-band, once the test contained in it are satisfied the parser revert back to the starting node and evaluate the rest of the xpath expression. The first two examples are a tipical