How do node.XPathSelectElement()
and node.XPathSelectElements()
behave when the selection is either not a NodeSet or a NodeSet containing non-Elements? For example do they always return something or can they throw Exceptions? can the return value be null or is it always an IEnumerable of some sort? The XML searched is constant:
<a>
<b c="d"/>
<e>fgh</e>
<e>xyz</e>
<!-- comment -->
<b/>
</a>
To illustrate this here are some XPath strings; I would be grateful for the behaviour of both XPathSelectElement and XPathSelectElements in each case (I have put the expected XSLT NodeSet below - please comment if you disagree)
//a
//b
//b[1]
//c
//@c
//b | //@c
//e/text()
//comment()
count(//b)
and expected return values
- 1 element
- 2 elements
- 1 element
- 0 elements
- 1 attribute node
- 2 elements and 1 attribute
- 2 text nodes
- 1 comment node
- the integer 2
If the Xpath does not return an IEnumerable of Elements (XPathSelectElements) or a single Element (XPathSelectElement) is any indication given or is the failure silent?