Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SelectSingleNode without namespace

Tags:

.net

xml

I'm using .Net 2.0, and need to SelectSingleNode from my XmlDocument regardless of namespace, as wrong headed as that may sound.

to be specific

XmlElement slipType = (XmlElement)document.SelectSingleNode("//Provenance1");

will set slipType to null since I don'l know th namespace Provenance1 is in at the time of the query.

like image 260
Ralph Shillington Avatar asked Sep 24 '09 14:09

Ralph Shillington


1 Answers

You can check the local-name of the element and ignore namespace with the following XPath expression:

//*[local-name()='Provenance1']
like image 112
Mads Hansen Avatar answered Sep 24 '22 08:09

Mads Hansen