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
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:
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).