My xml looks like
<article>
<article-id pub-id-type="local">ABC</article-id>
<article-id pub-id-type="external">XYZ</article-id>
</article>
I can do the following
dim articleId as string = doc.SelectSingleNode("./article/article-id", nsm).InnerText
and the result is ABC
I don’t know how to get the result to be XYZ – I assume because I’m using SelectSingleNode it is getting the First item. Is there a way to tell it to get the second?
Please note, although I’ve shown an example with only 2 nodes, there could be any number so it must be ‘searchable’ by the name ‘external’
I’ve not really used .NET 2.0 before and the MSDN didn’t really help me.
Any help would be great, thank you.
You can use the following XPath:
The
[@pub-id-type='external']is an attribute filter.If you have multiple possible elements, you could add
[last()]to get the last of them.For more XPath info, check out this page.