Reputation: 1045
I have the following XPath 1.0 query:
/root/Nodes/*[self::CustomNode[not(../DefaultNode)]|self::DefaultNode]/Name
As I understand it, this will return /root/Nodes/CustomNode/Name
if it exists, or /root/Nodes/DefaultNode/Name
if it's not found. However, /root/Nodes/DefaultNode/Name
is being returned even when /root/Nodes/CustomNode/Name
is present. Any ideas how I can fix this?
DefaultNode
nodes always proceed CustomNode
nodes in the document order.
Thanks
Upvotes: 0
Views: 194
Reputation: 20620
Are you thinking the vertical line (|) works like an OR?
Here's the details: http://www.w3schools.com/xpath/xpath_operators.asp
| Computes two node-sets: //book | //cd Returns a node-set with all book and cd elements
Semantics:
It returns nodes that meet condition A OR condition B.
It returns nodes that meet condition A AND nodes that meet condition B.
Upvotes: 1