.net关于xml文件命名空间的解析读取

如XML文件:


<?xml version="1.0" encoding="utf-8" ?>
<SendExResp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<PayCount>1</PayCount>
	<BlackWords />
	<ErrorMobiles />
	<BlackMobiles />
	<BatchSendID>00000000-0000-0000-0000-000000000000</BatchSendID>
	<Result>aaa</Result>
	<ErrorDesc>成功</ErrorDesc>
</SendExResp>

C#代码

 String path = System.AppDomain.CurrentDomain.BaseDirectory + "//return.xml";

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(path);

                XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmldoc.NaMetable); //namespace 
                namespaceManager.AddNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");
                namespaceManager.AddNamespace("xsd","http://www.w3.org/2001/XMLSchema");

                XmlNode node = xmldoc.SelectSingleNode("//SendExResp/Result",namespaceManager);

                this.Label1.Text = node.InnerText;

相关文章

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