private static string Analysis(string strResult)
{
var doc = new System.Xml.XmlDocument();
//加载soap文件,文件格式如:strResult
doc.LoadXml(strResult);
string q1 = doc.DocumentElement["soap:Body"]["SendSmsResponse"].InnerXml;//该处是否必须,请各位大侠自己测试
doc.LoadXml(q1);
//xml 命名空间
XmlNamespaceManager xmlns = new XmlNamespaceManager(doc.NameTable);
//xml 命名空间缩写
xmlns.AddNamespace("H", "http://www.yysms.com/");
//获取xml文件<StatusCode></StatusCode>节点下的文本值
var s = doc.SelectSingleNode("/H:SendSmsResult/H:StatusCode", xmlns).InnerText;
return s
}
strResult:Soap文件
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SendSmsResponse xmlns="http://www.yysms.com/">
<SendSmsResult>
<PayType></PayType>
<StatusCode>OK</StatusCode>
<Description>操作成</Description>
<MsgId></MsgId>
<SuccessCounts></SuccessCounts>
<BillingCount></BillingCount>
<Amount></Amount>
<Balance></Balance>
<BillingAmount></BillingAmount>
<Errors />
</SendSmsResult>
</SendSmsResponse>
</soap:Body>
</soap:Envelope>