I’d like to do some math with some elements which contain a - in their name:
<containers>
<container>
<max-capacity>10</max-capacity>
<content>5</content>
</container>
<container>
<max-capacity>10</max-capacity>
<content>8</content>
</container>
</containers>
I’d like to execute an xpath query which counts the number of containers having a remaining capacity of > 2
count(containers/container[max-capacity-content>2])
but since there is a - in the name of the node max-capacity this doesn’t work.
What do I have to do to make this work?
(I don’t want to transform the xml to a --free document.)
Add spaces –
containers/container[max-capacity - content > 2]works according to http://www.xpathtester.com/test, and should work within acount()expression such as yours as well.