Database Reference
In-Depth Information
Something a Little More Practical—Parsing XML Response
Now that we've had a brief introduction to using NSURLRequest , we can use it to do
something a bit more useful than spitting out raw HTML in alerts. We still don't have
any web services from the backend developers, so we'll use a publicly available RESTful
web service provided by the US National Weather Service. Given an address such as:
http://www.weather.gov/forecasts/xml/sample_products/browser_interface/
ndfdXMLclient.php?zipCodeList=20910+25414&product=time-series&begin=2004
-01-01T00:00:00&end=2013-04-21T00:00:00&maxt=maxt&mint=mint
We can get back XML that looks like the sample shown in Example 4-3 .
Example 4-3. Sample XML from the National Weather Service
<dwml xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0"
xsi:noNamespaceSchemaLocation=\
"http://www.nws.noaa.gov/forecasts/xml/DWMLgen/\
schemaDWML.xsd">
<head>
<product srsName="WGS 1984"
concise-name="time-series"
operational-mode="official">
<title>
NOAA's National Weather Service Forecast Data
</title>
<field>meteorological</field>
<category>forecast</category>
<creation-date refresh-frequency="PT1H">
2011-07-25T00:30:56Z
</creation-date>
</product>
<source>
<more-information>
http://www.nws.noaa.gov/forecasts/xml/
</more-information>
<production-center>
Meteorological Development Laboratory
<sub-center>
Product Generation Branch
</sub-center>
</production-center>
<disclaimer>
http://www.nws.noaa.gov/disclaimer.html
</disclaimer>
<credit>
http://www.weather.gov/
</credit>
<credit-logo>
http://www.weather.gov/images/xml_logo.gif
</credit-logo>
 
Search WWH ::




Custom Search