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;

 

       

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM