RSS feed XML linq

R

Robert Bravery

Hi all,

I'm readming values from an rss feed, by way of the suplied xml file. Using
linq I can get the title and description, but need to know the last download
time. Can some one through me a hint. A snipit of the xml file
..

Thanks
Robert

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005">
<channel
xmlns:cfi="http://www.microsoft.com/schemas/rss/core/2005/internal"
cfi:lastdownloaderror="None">
<title cf:type="text">The PowerAlert South Africa Feed</title>
<link>http://www.poweralert.co.za/</link>
<description cf:type="text">Power Alert South Africa RSS
Feed</description>
<language>en-us</language>
<item>
<title xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005"
cf:type="text">National PowerAlert State Green Down @ 22:40, 1 March 2008
(local - GMT+2) - No load shedding currently.</title>
<link>http://www.poweralert.co.za/poweralert3/slider.php?region_id=1</link>
<description xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005"
cf:type="html">Green Up - No load shedding currently.</description>
<cfi:id>5</cfi:id>
<cfi:read>true</cfi:read>
<cfi:downloadurl>http://poweralert.co.za/poweralert3/rss.xml</cfi:downloadurl>
<cfi:lastdownloadtime>2008-03-01T20:44:26.651Z</cfi:lastdownloadtime>
</item>
 
M

Martin Honnen

Robert said:
I'm readming values from an rss feed, by way of the suplied xml file.
Using linq I can get the title and description, but need to know the
last download time. Can some one through me a hint. A snipit of the xml
file

XDocument doc = XDocument.Load(@"..\..\XMLFile1.xml");
XNamespace cfi =
"http://www.microsoft.com/schemas/rss/core/2005/internal";
foreach (XElement item in
doc.Root.Element("channel").Elements("item"))
{
Console.WriteLine("Item {0} downloaded at {1}.",
item.Element("title").Value, item.Element(cfi + "lastdownloadtime").Value);
}

This outputs the string value of the lastdownloadtime item, if needed
you could also convert it to a DateTime.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Need an explanation rss xml 4
Formatting raw XML? 3
Parsing RSS (XML) 4
auto-discover RSS feed 2
Rss feed 1
showing date on ashx page (rss) 4
IE7 RSS Feed Button 3
Simple XML parsing question.. 2

Top