Reading attributes from RSS feed

Posted on 2008-10-06
Last Modified: 2013-11-18
I'm trying to consume this RSS feed below. How do I get the min, max, etc attributes from the w:forecast node using the SyndicationFeed or some other method?

I did plan on using the class provided here to keep the code succinct.

MSDN reference to SyndicationFeed
WebClient client = new WebClient();

client.Proxy = new WebProxy(proxyAddress, true);

Stream strm = client.OpenRead("");

XmlReader reader = XmlReader.Create(strm);

SyndicationFeedFormatter formatter = SyndicationFormatterFactory.CreateFeedFormatter(reader);


SyndicationFeed feed = formatter.Feed;

Collection<string> timeToLive = feed.ElementExtensions.ReadElementExtensions<string>("ttl", "");

double ttl = 30;

if (timeToLive.Count > 0)

    ttl = Double.Parse(timeToLive[0]);

Open in new window

Question by:brene
  • 3
  • 2
LVL 13

Expert Comment

ID: 22657834
are you using .net 3.5?

Author Comment

ID: 22664926
Yes, that is why I want to take advantage of the SyndicationFeed class but I'll use any method that works.
LVL 13

Expert Comment

ID: 22666401

Author Comment

ID: 22666763
That link shows how to create a feed. I'm trying to get the data from an existing feed so that doesn't help.

What I want is the information contained in the w:forecast node eg.
<w:forecast day="Thursday" description="Early Fog Followed by Sun. Mild." min="8" max="21" icon="12" iconUri="" iconAlt="Early Fog Followed by Sun"/>

Accepted Solution

brene earned 0 total points
ID: 22684156
Worked it out myself.
var items = from i in feed.Items

			select new


				Title = i.Title.Text,

				Link = i.Links[0].Uri.ToString(),

				Ext = i.ElementExtensions


foreach (var item in items)


	currWeather.Title = item.Title;

	currWeather.Link = item.Link;

	foreach (SyndicationElementExtension extension in item.Ext)


		if (extension.OuterName == "current")


			XmlReader xReader = extension.GetReader();

			if (xReader.HasAttributes)


				currWeather.Temperature = Double.Parse(xReader["temperature"]);

				currWeather.DewPoint = Double.Parse(xReader["dewPoint"]);

				currWeather.Humidity = Double.Parse(xReader["humidity"]);

				currWeather.WindSpeed = Double.Parse(xReader["windSpeed"]);

				currWeather.WindGusts = Double.Parse(xReader["windGusts"]);

				currWeather.WindDirection = xReader["windDirection"];

				currWeather.Pressure = Double.Parse(xReader["pressure"]);

				currWeather.Rain = Double.Parse(xReader["rain"]);





Open in new window


Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now