I would like to select all elements that have certain attribute or don't have it at all:
//job[@salary<"100" or !@salary]
This code is not valid. Which one is? Thanks!
0 votes. Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
XPath Tutorial from basic to advance level. This attribute can be easily retrieved and checked by using the @attribute-name of the element. @name − get the value of attribute "name". <td><xsl:value-of select = "@rollno"/></td> Attribute can be used to compared using operators.
//job[@salary<"100" or not(@salary)]
There isn't a not operator in xpath. See http://www.w3schools.com/xpath/xpath_operators.asp
//job[@salary<"100" or count(@salary)=0]
Tested it here and works fine.
//job[count(@salary) = 0]
I think :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With