Need help writing xpath expression on xml response returned from WeatherWS app -
i'm struggling write xpath expression extract values returned following xml response.
<soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body> <getcityforecastbyzipresponse xmlns="http://ws.cdyne.com/weatherws/"> <getcityforecastbyzipresult> <success>true</success> <responsetext>city found</responsetext> <state>md</state> <city>columbia</city> <weatherstationcity>baltimore</weatherstationcity> <forecastresult> <forecast> <date>2011-10-08t00:00:00</date> <weatherid>4</weatherid> <desciption>sunny</desciption> <temperatures> <morninglow>48</morninglow> <daytimehigh>78</daytimehigh> </temperatures> <probabilityofprecipiation> <nighttime>00</nighttime> <daytime>00</daytime> </probabilityofprecipiation> </forecast> <forecast> <date>2011-10-09t00:00:00</date> <weatherid>4</weatherid> <desciption>sunny</desciption> <temperatures> <morninglow>50</morninglow> <daytimehigh>83</daytimehigh> </temperatures> <probabilityofprecipiation> <nighttime>00</nighttime> <daytime>00</daytime> </probabilityofprecipiation> </forecast> <forecast> <date>2011-10-10t00:00:00</date> <weatherid>4</weatherid> <desciption>sunny</desciption> <temperatures> <morninglow>53</morninglow> <daytimehigh>82</daytimehigh> </temperatures> <probabilityofprecipiation> <nighttime>00</nighttime> <daytime>00</daytime> </probabilityofprecipiation> </forecast> <forecast> <date>2011-10-11t00:00:00</date> <weatherid>2</weatherid> <desciption>partly cloudy</desciption> <temperatures> <morninglow>57</morninglow> <daytimehigh>78</daytimehigh> </temperatures> <probabilityofprecipiation> <nighttime>10</nighttime> <daytime>10</daytime> </probabilityofprecipiation> </forecast> <forecast> <date>2011-10-12t00:00:00</date> <weatherid>6</weatherid> <desciption>showers</desciption> <temperatures> <morninglow>60</morninglow> <daytimehigh>71</daytimehigh> </temperatures> <probabilityofprecipiation> <nighttime>50</nighttime> <daytime>60</daytime> </probabilityofprecipiation> </forecast> <forecast> <date>2011-10-13t00:00:00</date> <weatherid>6</weatherid> <desciption>showers</desciption> <temperatures> <morninglow>61</morninglow> <daytimehigh>69</daytimehigh> </temperatures> <probabilityofprecipiation> <nighttime>60</nighttime> <daytime>50</daytime> </probabilityofprecipiation> </forecast> <forecast> <date>2011-10-14t00:00:00</date> <weatherid>2</weatherid> <desciption>partly cloudy</desciption> <temperatures> <morninglow>59</morninglow> <daytimehigh>70</daytimehigh> </temperatures> <probabilityofprecipiation> <nighttime>30</nighttime> <daytime>40</daytime> </probabilityofprecipiation> </forecast> </forecastresult> </getcityforecastbyzipresult> </getcityforecastbyzipresponse> </soap:body> </soap:envelope>
can write xpath expression extract success property value 'true' response.
i've been using following online tool - http://www.freeformatter.com/xpath-tester.html test attempts, each attempt returned !no match.
here xpath expression though correct:
//getcityforecastbyzipresponse//getcityforecastbyzipresult//success
hope can help.
p.s webservice used generate response can found here: http://wsf.cdyne.com/weatherws/weather.asmx - i'm using getcityforecastbyzip service. cheers!
this due namespaces either have 'register' them upfront in used xpath engine or use xpath based solely on element name below
//*[local-name()='getcityforecastbyzipresponse']/*[local-name()='getcityforecastbyzipresult']/*[local-name()='success']
Comments
Post a Comment