微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 来自Web服务的XML结果

我想从webservice获取XML结果.我试过下面的代码

    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;

但我无法得到结果,它显示错误名称空间前缀’soapenv’未定义.任何帮助对我都有帮助.

解决方法:

这是解决注册infopath前缀的问题.例如,您为“xsl”所做的.

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

所以看起来应该是这样的,

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。