XML result from web service

I want to get XML result from webservice. I tried the code below

    XmlDocument doc = new XmlDocument();

    string xml = "http://www.examplexml.com/2323223";

    doc.Load(xml);
    var nsmgr = new XmlNamespaceManager(doc.NameTable);
    nsmgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");

    XmlNode node = doc.SelectSingleNode("/-soapenv:Envelope/-soapenv:Body/
                                                -GetPasswordResponse/Password", nsmgr);
    string password = node.InnerText;

But I could not get the result. It shows an error. The soapenv namespace prefix is ​​undefined. Any help would be helpful to me.

+4
source share
1 answer

This solves your problem for registering infopath prefixes. For example, as you did for "xsl".

nsmgr.AddNamespace("soapenv", "Here is the URL of mention at starting point in your xml file");

So it should look like this:

nsmgr.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
+2
source

Source: https://habr.com/ru/post/1584204/


All Articles