如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;原文链接:https://www.f2er.com/xml/300201.html