c# 对SOAP返回XML字符串的解析方法

示例:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <SalesResponse
            xmlns="http://timea.org/">
            <SalesResult>{"Success":false,"ErrorMessage":
{"Message":"E-Operation无此料号.E-Operation无此PO.库存不足,请先增加库存!","Lines":[]}}</SalesResult>
        </SalesResponse>
    </soap:Body>
</soap:Envelope>

针对以上进行解析,解析代码

 

try
                                {
                                    XmlDocument xmlDoc = new XmlDocument();
                                    xmlDoc.LoadXml(agbsresult);//Load加载XML文件,LoadXML加载XML字符串
                                    string value = xmlDoc.DocumentElement["soap:Body"]["SalesResponse"]["SalesResult"].InnerXml;

                                }
                                catch (Exception)
                                {

                                    throw;
                                }

        return value;

       

猜你喜欢

转载自www.cnblogs.com/ling-cun/p/11635590.html