Can somebody explain me why is this not working?
I'm executing
XmlNode xmlNode = xmlDocument.SelectSingleNode("//(artist|author)");
and I get
System.Xml.XPath.XPathException: Expression must evaluate to a node-set.
but this works and does not raise the exception even when there are many artist nodes
XmlNode xmlNode = xmlDocument.SelectSingleNode("//artist");
To my knowledge you can use '|' just at the top level of an XPath Query, so try the query
"//artist|//author"
Bye the way doing recursive searches (//) isn't very fast, so make sure your dom document is small.
Update:
I looked it up in the specification:
3.3 Node-sets
A location path can be used as an expression. The expression returns the set of nodes selected by the path.
The | operator computes the union of its operands, which must be node-sets.
That means whatever you write left and right of "|" needs to be usable as an xpath query on its own, the "|" then just creates the union from it.
Specifically you can not say "search recursively for (something called author OR something called artist)" because "something called author" does not evaluate to the result of an xpath-query (a node set).