Subject: how to xpath the *value* of an attribute based on value of other attribute in same element
From: dan haig <haignlx@xxxxxxxxx>
Date: Wed, 1 Jul 2009 13:42:10 -0400
|
Hi, sorry if this has been answered a hundred times but I haven't had
much luck finding this in the archives.
For this xml:
<xtf:snippets>
<xtf:snippet score="100" rank="1" hitNum="5">
MS Clark Library, University of
<xtf:hit>
<xtf:term>California</xtf:term>
</xtf:hit>. 40 Albion Street Broadstairs |
</xtf:snippet>
</xtf:snippets>
... I want to write an xpath that will select just the numeric value
of 5 for the attribute hitNum, based on its being a sibling attribute
of rank="1". However, I can't get any closer than selecting the whole
xtf:snippet element. This are a couple ways of accessing that
inadequate result:
/xtf:snippets/xtf:snippet[@rank='1']/attribute::hitNum
/xtf:snippets/xtf:snippet[@rank='1']/@hitNum
I can't seem to get it to cough up just the 5. It would seem trivial,
but neither reference books nor any website I have found addressed it.
Any clues please, thanks.
.d
|