I want to determine if a node contains the string abc using following-sibling.
So far I’m looping through each item node and I want to determine if that item contains a node with the string abc
This is what i’ve tried so far:
contains(node/following-sibling::node[text()], 'abc')
XML:
<doc>
<item>
<node>1abc2</node>
<node>4</node>
<node>x</node>
</item>
<item>
<node>1</node>
<node>2abcX</node>
<node>x</node>
</item>
</doc>
If all you’re trying to do is “determine if that
itemcontains anodewith the stringabc“ then you don’t needfollowing-sibling. Use this to select all such nodes:This matches a
nodein bothitemelements provided.If you want to check for a child
nodehaving a following siblingnodewith that text, then use:This only matches the first
nodein the seconditem.Either of these can be explicity converted to a boolean with the
booleanfunction. For example:This returns true if at least one node is selected by the expression (i.e. the node-set is non-empty).