O'Reilly logo

HTML5 Web Application Development By Example Beginner's guide by J.M. Gustafson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – getting XML data

First let's create an example of getting data from an XML file and updating the weather widget from its data. We will create a new web page called weather.html and put the markup for the weather widget into it. This page will have a Check Weather button. When clicked, it will call the weather widget's update() method. You can find the code for this example in Chapter 8/example8.1.

Next we need to create an XML file with some weather information in it. We will name the file weather.xml and place it in the data folder:

<weather> <location>Your City</location> <current_observation> <weather>Snow</weather> <temperature_string>38.3 F (3.5 C)</temperature_string> <feelslike_string>38 F (3 C)</feelslike_string> <relative_humidity>76%</relative_humidity> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required