Example Code

Simple Weather XML Program

Code and Documents

Attachment

Download All

Overview

This project parses XML from both wunderground.com and weather.gov to get the weather stations and weather information closest to your city. The data is then presented on the front panel.

Description

The top-level weather VI reads the front panel zip code indicator and gets the XML URL using the Station VI and Get ID Name VI to get the Station ID (e.g. KCNU). Since weather.gov has the same basic URL format for all weather station IDs, we can poll Wunderground's website to find the closest weather station to your location. This is done by using the websites "query" method within the URL. We can pass it a zipe code or a city/state and it will return the closest weather stations.

These weather stations are fed into a ring control so the user can select which station he/she wants to read. The finalized weather.gov URL with the proper station ID is then fed into the Get Data VI which parses the XML and displays the information in the form of a cluster.

This example is not a stand-alone application, only a demonstration of parsing XML using XPathes, receiving XML data from a URL, and leveraging existing XML feeds on the internet to retrieve data.

Capture.JPG

Steps to Run

1. Type in your zipe code or City,State

2. Click the Run arrow

3. Choose weather station from drop down

4. If weather station is already chosen, hit the "Get Weather Data" button to populate the information

Requirements

I created this project using LabVIEW 2012, but I also saved the project in LabVIEW 8.5 for backwards compatibility.

Tannerite
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors