Как получить значения из этого XML-ответа в C # для winforms - PullRequest
0 голосов
/ 23 июня 2011

Вот ответ XML:

  <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>"

Я пытаюсь получить значения из элемента XML: 'isCovered' Я могу получить значения из

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

НоМне нужно значение для IsCovered.

C # код:

  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;
                       }
                    }

1 Ответ

0 голосов
/ 23 июня 2011

Вы можете использовать SoapFormatter для десериализации вашего потока ответов.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...