The returned XML document has a default namespace. Unfortunately, the
XmlDocument
doesn't make it easy to select nodes with a default namespace. You need to create an
XmlNamespaceManager
, add a namespace prefix for the default namespace, and change your XPath expression to use the new namespace prefix:
XmlDocument document = new XmlDocument();
document.Load("http://ws.cdyne.com/ip2geo/ip2geo.asmx/ResolveIP?IPaddress=49.14.147.196&LicenseKey=0");
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(document.NameTable);
namespaceManager.AddNamespace("x", document.DocumentElement.NamespaceURI);
XmlNode node = document.SelectSingleNode("/x:IPInformation/x:Country", namespaceManager);
string name = node.InnerText;