Given a XmlNode object, I needed to get the first children node by name. I used the SelectSingleNode method, providing a valid Xpath, but it didn’t work.
For example, I need to get the first child node named Signature from the xmlNode
XmlNode xmlNode = ..... // Initialise/assign the xmlNode variable
var signatureNode = xmlNode.SelectSingleNode("descendant::Signature");
It took me a bit of time to realise that the Signature node has a namespace, hence it returns null with that Xpath.
The below updated Xpath will tell it to select the node ignoring all the namespaces
XmlNode xmlNode = ..... // Initialise/assign the xmlNode variable
var signatureNode = xmlNode.SelectSingleNode("//*[local-name()='Signature']");