PDA

View Full Version : Best way to read In weather XML from weather.gov?



toddlemoine
15 Mar 2011, 5:46 AM
Hi,

I'm trying to cobble together a simple weather checking app using Sencha Touch and am hitting a wall trying to read XML generated by weather.gov's REST api. For now, I'm just trying to get my app to read XML generated by a query offered on their documentation page (http://www.weather.gov/forecasts/xml/rest.php):

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

They don't provide a way to add a callback param, so I'm left using a ScriptTag proxy. However, when the app loads and the xml is to be added to the page, I get this error in the console:

Uncaught SyntaxError: Unexpected token <

Because of the <dwml opening tag. The proxy is configured to use an XMLReader to parse (I'll include my CoffeeScript pseudocode below), but I'm not sure what to do at this point. Is there a better proxy to use, or a particular way to configure the XMLReader to parse this?

Thanks for any help. Here's what my store looks like:


app.stores.weatherconditions = new Ext.data.Store
model: 'WeatherCondition'
proxy:
type: 'scripttag'
url: '(the url from above)'
reader:
type: 'xml'
root: 'head'

Cheers,
-t

d5chris
15 Mar 2011, 2:13 PM
In the sencha examples, there's an example that uses JSONP to pull weather data from another site - maybe you should look at how its done there.

Go here:
http://dev.sencha.com/deploy/touch/examples/kitchensink/

Then click on Data > JSON P