locked
Parse XML returned from service RRS feed

  • Question

  • User-131059102 posted

    I'm playing around with WebServicex services.... 

    I'm using the following to return data based on a city name:

     DataReference.USZipSoapClient blah = new DataReference.USZipSoapClient("USZipSoap");
                var result = blah.GetInfoByCity(tbCityName.Text).OuterXml;

    This returns me the following:

    <NewDataSet xmlns=""><Table><CITY>Marana</CITY><STATE>AZ</STATE><ZIP>85653</ZIP><AREA_CODE>520</AREA_CODE><TIME_ZONE>M</TIME_ZONE></Table></NewDataSet>

    How can I parse this to appear on the page by node... such as City = Marana  State = AZ  etc... 

    Thanks!!!!

    Wednesday, February 24, 2016 7:12 AM

Answers

  • User-131059102 posted

    I ended up changing OuterXml to InnerXml

    and using the following:

     XmlDocument docArticle = new XmlDocument();
                docArticle.LoadXml(result);
    
                XmlNodeList nodeCity = docArticle.ChildNodes[0].SelectNodes("CITY");
    
    

    I could than just print out the City on the page.... or any other node as needed.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 24, 2016 8:50 AM