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> <wind_string>From the WSW at 1.0 MPH</wind_string> <...