简体   繁体   中英

How do I retrieve values from this XML response in C# for winforms

Here is the XML response:

  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="somehttp..">
      <soap:Body>
        <get4GAddressResponse xmlns="http://somelink/">
          <get4GCAddressResult>
            <located>true</located>
            <matchStatus>S</matchStatus>
            <errorCode>0</errorCode>
            <message>Single Address Match</message>
            <addressList>
              <anyType xsi:type="Address">
                <street>4301 some St</street>
                <city>ABC</city>
                <state>TX</state>
                <zip>78751</zip>
                <longitude>-97.700000</longitude>
                <latitude>30.308000</latitude>
                <coverageTypes>
                  <anyType xsi:type="NetworkCoverage">
                    <type>4G</type>
                    <isCovered>false</isCovered>
                  </anyType>
                </coverageTypes>
              </anyType>
            </addressList>
          </get4GAddressResult>
        </get4GAddressResponse>
      </soap:Body>
    </soap:Envelope>"

I am trying to get the values from XML element: 'isCovered' I am able to retrieve the values from

  <located>true</located>
            <matchStatus>S</matchStatus>
            <errorCode>0</errorCode>
            <message>Single Address Match</message>

But I need value for IsCovered.

C# code:

  Location result = new TestWebService.Location(); 
    result = get4GAddress(street, city, state, zip);
                    if (result != null)
                    {
                        if (result.errorCode.Equals("0"))
                        {
                            locationresult = new LocationResponse();
                            locationresult.located = result.located;
                            locationresult.addressList = result.addressList;
                            locationresult.matchStatus = result.matchStatus;
                            locationresult.message = result.message;
                       }
                    }

您可以使用SoapFormatter反序列化响应流。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM