开发者

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

开发者 https://www.devze.com 2023-03-15 10:14 出处:网络
Here is the XML response: <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"somehttp..\">

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&g开发者_JAVA百科t;
          </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;
                       }
                    }


You can use the SoapFormatter to deserialize your response stream.

0

精彩评论

暂无评论...
验证码 换一张
取 消