JS wrote:
> I have the below xml file:
>
> <root>
> <row order="0">
> <data id="LT1" value="Width"/>
> <data id="item" value="40 cm"/>
> </row>
> <row order="1">
> <data id="LT1" value="Height"/>
> <data id="item" value="20 cm"/>
> </row>
> </root>
>
> I would like to define a XPath variable where id=LT1. I have tried:
>
> Name: LT1
> XPath: @id="LT1"
>
> But when I use the "new" variable LT1 it returns nothing. How do I make
> a new variable which only extracts data where id=LT1?
It is not clear to me what exactly you want to achieve.
The XPath
/root/row[data[@id = 'LT1']]
would select all 'row' element children of the 'root' element which have
a 'data' child with the 'id' attribute value being 'LT1'.
If you do not want to select the 'row' elements but rather the 'data'
elements then use
/root/row/data[@id = 'LT1']
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/