I have XML documents like:
<rootelement>
<myelement>test1</myelement>
<myelement>test2</myelement>
<myelement type='specific'>test3</myelement>
</rootelement>
I'd like to retrieve the specific myelement
, and if it's not present, then the first one. So I write:
/rootelement/myelement[@type='specific' or position()=1]
The XPath spec states about the 'or expression' that:
The right operand is not evaluated if the left operand evaluates to true
The problem is that libxml2-2.6.26 seems to apply the union of both expressions, returning a "2 Node Set" (for example using xmllint --shell
).
Is it libxml2 or am I doing anything wrong ?