Mike P wrote:
I have limited experience of XML and I am trying to use XPath to get at
all <tag4> elements given a certain value for <tag3> (see my example
below :
<?xml version="1.0" encoding="ISO-8859-1"?>
<tag1>
<tag2>
<tag3>
<tag4>
<tag4>
<tag4>
</tag2>
<tag2>
<tag3>
<tag4>
<tag4>
</tag2>
</tag1>
You are missing a lot of closing tags above, also <tag3> elements do no
even have a content so it is not clear what you want to regard as the
value of <tag3>.
Assuming you had the following XML
<?xml version="1.0" encoding="UTF-8"?>
<tag1>
<tag2>
<tag3>Kibology</tag3>
<tag4 />
<tag4 />
<tag4 />
</tag2>
<tag2>
<tag3>whatever</tag3>
<tag4 />
<tag4 />
</tag2>
<tag2>
<tag3>Kibology</tag3>
<tag4 />
<tag4 />
</tag2>
</tag1>
and wanted to look for all <tag4> elements that have a preceding sibling
<tag3> element with the content (value) Kibology you could use the
following XPath expression:
/tag1/tag2/tag4[preceding-sibling::tag3 = 'Kibology']
--
Martin Honnen
http://JavaScript.FAQTs.com/