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/");

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念