• XmlDocument解析Soap格式文件案例:


     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>0</PayType>
             <StatusCode>OK</StatusCode>
             <Description>操作成</Description>
             <MsgId>1611084043570792</MsgId>
             <SuccessCounts>1</SuccessCounts>
             <BillingCount>1</BillingCount>
             <Amount>909</Amount>
             <Balance>0</Balance>
             <BillingAmount>0</BillingAmount>
             <Errors />
               </SendSmsResult>
        </SendSmsResponse>
        </soap:Body>
    </soap:Envelope>
  • 相关阅读:
    什么是Python???
    python中闭包详解
    python类中的__init__和__new__方法
    python中不需要函数重载的原因
    装饰器详解
    IDEA中导入非maven项目(从eclipse中迁移过来的)
    CLion、cmake、mingw、openCV安装
    跨域问题的一些思考
    maven中jar包手动导入
    对于序列化的理解
  • 原文地址:https://www.cnblogs.com/rengke2002/p/6046126.html
Copyright © 2020-2023  润新知