I have a following XML.
<root>
<a>
</a>
<a b="ar34" >
</a>
<a c="utr45">
</a>
</root>
I want to do the count where attribute “b” is not present.
I am using the following but not getting the count
count(//*[string-length(a/@b) = 0]
How I can do this? Thanks
Here’s a verbose explanation:
<a>tags. So you start withcount( a )<a>tags? Everywhere in the document. Socount( //a )it is then.<a>tags, so you have to use a predicate (the bit in the square brackets):count( //a[ ... ] )@battribute, so you putnot(@b)in the predicate. (You can do this because an attribute interpreted as a boolean is true if the attribute is present and false if it isn’t.)