читать мыло XML тело в c # - PullRequest
0 голосов
/ 16 мая 2018

я хочу прочитать <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>

1 Ответ

0 голосов
/ 16 мая 2018

Так что я предполагаю, что ваш код работает отлично до этого момента.Я также не знаю, как выглядит ваш 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");
      }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...