Retrieving XML data from Weather.com

Many peaple asked me how to retrieve “simple” XML data from a HTTP based server. Here you get an example…

The Weather Channel

The Weather Channel

The Weather Channel for example provides this kind of service (free of charge). They call it XOAP, XML Weather Feed.

To be able to receive data (for non-commercial use), you’ll need to sign up for an account (don’t worry! They won’t spam you)

http://registration.weather.com/registration/xmloap/step1

Most of those HTTP based XML feeds need a simple URL to query the data.
For TWC it looks like this:

http://xoap.weather.com/weather/local/[location]?cc=*&link=xoap&prod=xoap&par=[partnerID]&key=[password]&unit=m

The three fields (location, partnerID and password) have to be filled with the proper information. Without a valid account you won’t receive any data!
The location code can be found on the www.weather.com web site. Simply query a location and copy the code from your browsers address bar. Hamburg, Germany for example has the location code: GMXX0049

The Weather Data Content Container

With the URL node of Ventuz its easy to construct this kind of URLs. The resulting URL is passed to an XML File node to receive the actual XML data. The Ventuz Express edition will stop rendering during this process, because it can’t handle the request in the background. The Broadcast/Professional editions don’t interfere the rendering, because the XML request is marked to be processed asynchronously.

Several XPath nodes are used to select the required information from the returned XML document. This values are “exposed” from the Container to make them easily accessible for other Ventuz nodes.

I’ve created a simple Ventuz Repository with some elements to acces TWC XML data. Simply download the repository here:

The Weather Channel REPOSITORY

… unzip it at you preferred location and open the Repository in you Project within the Ventuz Designer.

You’ll find 3 items:

  • The “Weather Data” content node. This node hold all logic to receive the data and provides usefull output properties to handle/display the incoming data.
  • The “Weather Icon” hierarchy node simply loads the correct icon texture depending on an icon number. The number matches exactly the icon codes of TWC.
  • An “Example” scene, which show how you could use this two elements in conjunction with simple text fields and arrange nodesTo open the scene from the Repository, click on the “New Scene from Wizard” button and select “Example”.
    newscenewiz
    scenerootBtw, if you want to provide Scene-Templates within your own repositories, simply drag and drop the Scene-Root into it.
    As soon a user has opened that repository in his/her project, the “New Scene Wizard” will show all contained as available scene templates!

weatherdisplay

Have fun!

Ralf

1 Comment

  1. Comment shmai says:

    This is classic asp script will allow you to monitor your current local weather via a Weather.com XML feed.
    It parses the XML data and then outputs formatted HTML.
    You need to acquire a Partner ID and License Key from Weather.com.
    This service is completely free, and they only want your email. Visit this URL to sign up.

Leave a Reply