Reputation: 91
I'm trying to use the value of an XML node to select a group of nodes, my specific problem is the following. I have the nodes computers with the attribute model and in their children is the node HardDrive
<PC model="Lindows OSX">
<HardDrive>500</HardDrive>
</PC>
I'd like to select only the PCs which HardDrive is over 500gb, so I dont know if the function text() let's me work with numbers, something like
//parent::HardDrive[text()>500]/@model
Upvotes: 1
Views: 52
Reputation: 34189
You can use the following XPath:
root/PC[HardDrive[. > 500]]/@model
It will extract all model names of PCs with hard drive capacity > 500.
Demo at xpathtester.com.
Upvotes: 1
Reputation: 56162
[text()>500]
is a valid XPath condition.
That's what you want I reckon:
//PC[HardDrive > 500]/@model
Upvotes: 2