Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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
test="whatever"
<xsl:if test="count(//a) > 0">Yes</xsl:if>
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.
test
Add a comment
Maybe you don't need the "" marks.
From the free tool XPathBuilder:
http://www.bubasoft.net/product/xpath-builder/
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
test="whatever"is not an XPath expression; it's an attribute of an XSLT instruction, e.g.<xsl:if test="count(//a) > 0">Yes</xsl:if>.