Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

RSS feed XML linq

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Bravery - 02 Mar 2008 12:21 GMT
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>
Martin Honnen - 02 Mar 2008 12:57 GMT
> 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.
Signature


    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Robert Bravery - 02 Mar 2008 13:19 GMT
Brilliant.
Thanks.
I forgot the XNamespace

Robert

>> 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
[quoted text clipped - 13 lines]
> This outputs the string value of the lastdownloadtime item, if needed you
> could also convert it to a DateTime.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.