• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 506
  • Last Modified:

Read data from XML Feed

This url returns weather data from the BBC:


This is the returned XML:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" version="2.0">
    <atom:link href="http://open.live.bbc.co.uk/weather/feeds/en/2633563/observations.rss" rel="self" type="application/rss+xml" />
    <title>BBC Weather - Observations for  Worcester, United Kingdom</title>
    <description>Latest observations for Worcester from BBC Weather, including weather, temperature and wind information</description>
    <copyright>Copyright: (C) British Broadcasting Corporation, see http://www.bbc.co.uk/terms/additional_rss.shtml for more details</copyright>
    <pubDate>Fri, 04 Oct 2013 07:14:54 +0100</pubDate>
      <title>Friday - 06:00 BST: Light Rain Shower, 17°C (63°F)</title>
      <description>Temperature: 17°C (63°F), Wind Direction: Southerly, Wind Speed: 14mph, Humidity: 88%, Pressure: 1003mb, Falling, Visibility: Good</description>
      <pubDate>Fri, 04 Oct 2013 07:14:54 +0100</pubDate>
      <guid isPermaLink="false">http://www.bbc.co.uk/weather/2633563-2013-10-04T07:14:54.000+01:00</guid>
      <georss:point>52.18935 -2.22001</georss:point>

Open in new window

I want my website to display something like this:

Thursday - 16:00 BST:
Thick Cloud, 18°C (64°F)

Temperature: 18°C (64°F)
Wind Direction: East South Easterly
Wind Speed: 14mph
Humidity: 89%
Pressure: 1003mb Falling
Visibility: Very Good

How could I do this?

Andy Green
Andy Green
1 Solution
Asim NazirCommented:
You can use following for reading xml:

- XML classes in .Net class library. Follow http://support.microsoft.com/kb/307643 for more details.
<link to competing site removed - GaryC123 4th Oct 2013>
Carl TawnSystems and Integration DeveloperCommented:
You can retrieve the XML and grab the contents of the two nodes you need using something like:
XmlDocument doc = new XmlDocument();
doc.Load(new XmlTextReader("http://open.live.bbc.co.uk/weather/feeds/en/2633563/observations.rss"));

XmlNode item = doc.SelectSingleNode("rss/channel/item");

string title = item["title"].InnerText;
string description = item["description"].InnerText;

Open in new window

Once you have that, you can parse and display however you want.
Andy GreenAuthor Commented:
Thanks for this - just what I needed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now