【问题标题】:read soap XML body in c#在 C# 中读取肥皂 XML 正文
【发布时间】:2018-05-16 10:10:24
【问题描述】:

我想阅读<PointTransactionStatus>true</PointTransactionStatus> 正如我使用下面的代码

XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Result");
string Short_Fall = string.Empty;
foreach (XmlNode node in nodeList)
{
    Short_Fall = node.InnerText;

请推荐

<ApiResponseModel xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <IsSuccess>true</IsSuccess>

  <StatusCode>OK</StatusCode>

  <Result xsi:type="xsd:string">
    <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
        <a1:PointTrasactionSoapResponse id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/Coop.Lms.Model.SoapXML.Response/Coop.Lms.Model%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">
          <PointTransactionStatus>true</PointTransactionStatus>
        </a1:PointTrasactionSoapResponse>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
  </Result>

</ApiResponseModel>

【问题讨论】:

    标签: c# xml-parsing


    【解决方案1】:

    所以我假设你的代码运行完美,直到这一点。我也不知道你的 XML 看起来如何。所以只需编辑下面的代码:

    XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Result"); 
    
    string Short_Fall = string.Empty; 
    
    foreach (XmlNode node in nodeList) 
    { 
      Short_Fall = node.InnerText;
    
       if( Short_Fall == "insert result you are looking for")
           {
             //Where you want the print to happen comes below
             Console.WriteLine("True");
           }
          else
          {
             //Where you want the print to happen comes below
             Console.WriteLine("OK");
          }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-08
      相关资源
      最近更新 更多