I have this XML SOAP response from a server that I don't control:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetResponse xmlns="http://Door.Application.DataService/">
<GetResult>C5465781005937173259</GetResult>
</GetResponse>
</s:Body>
</s:Envelope>
I am using this C# code to try to extract the text from the GetResult element:
// xdoc is an XmlDocument with the above XML contained within
XmlDocument xdoc = ...
// Add namespace manager
var nsmgr = new XmlNamespaceManager(xdoc.NameTable);
nsmgr.AddNamespace("", "http://Door.Application.DataService/");
nsmgr.AddNamespace("s", "http://schemas.xmlsoap.org/soap/envelope/");
XmlNode titleNode = xdoc.SelectSingleNode("/s:Envelope/s:Body/GetResult/GetResponse", nsmgr);
If I query just the "s" namespace prefixed element, then I do get the result in titleNode. But if I try to get specific about it and include the GetResult and/or GetResponse elements, I always get null in the titleNode variable.
I can find many articles about C# XPath with namespaces and with just the default namespace but I can't find anything where part of the XML has an explicit namespace and part of it has the default namespace.