timpham
timpham

Reputation: 565

xpath query conditional test comparing 2 numeric values

can someone explain to me why this condition return false in this following xpath query

xml

<?xml version="1.0" encoding="UTF-8"?>
<a>ha</a>

xpath query

count(//a) return 1.

but

test="(count(//a) > 0)" return false?

Thank you

Upvotes: 0

Views: 410

Answers (2)

Michael Kay
Michael Kay

Reputation: 163342

In the query

test="(count(//a) > 0)"

test refers to a child element of the document node called "test". If there is no such element (which is the case here), then you are comparing an empty set to the string "count(//a) > 0". Comparing an empty set to anything returns false.

Upvotes: 2

Steve Wellens
Steve Wellens

Reputation: 20620

Maybe you don't need the "" marks.

From the free tool XPathBuilder:

enter image description here

http://www.bubasoft.net/product/xpath-builder/

Upvotes: 1

Related Questions