简体   繁体   English

来自Web服务的XML结果

[英]XML result from web service

I want to get a XML result from the webservice. 我想从webservice获取XML结果。 I have tried the below code 我试过下面的代码

    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 couldn't get the result, It shows the error Namespace prefix 'soapenv' is not defined. 但我无法得到结果,它显示错误名称空间前缀'soapenv'未定义。 Any help would be helpful for me. 任何帮助对我都有帮助。

This is solve your problem to register infopath of prefixes. 这是解决注册infopath前缀的问题。 For example as you did for "xsl". 例如,您为“xsl”所做的。

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

So it should be look like this, 所以看起来应该是这样的,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM