I have a class named rssnews.cs it's constructor takes five strings
title
description
pubDate
Author
link
I have an XML document that has lots of news storys, like this
<item> <title> title here </title> <description> description here </description> <pubDate> date here </pubDate> <Author> john smith </Author> <link> http://sdasdd.com </link> </item> <item> <title> title here </title> <description> description here </description> <pubDate> date here </pubDate> <Author> john smith </Author> <link> http://sdasdd.com </link> </item>
I need to get each one of these is to an rssnews object which inturn is in a list of rssnews objects but I just cant seem to navigate this very well, I can see them all in the debuger but i just cant get them!! it's me though they are clearly there.
So my code
List<rssnews> newsList = new List<rssnews>();
public List<rssnews> GetRssNews (string username, string password) {
WebClient client = new WebClient();
CookieContainer cookie = new CookieContainer();
client.Credentials = new NetworkCredential(username, password, "chester");
XDocument xmlDoc = Xdocument.Parse(client.DownloadString(new Uri("https://portal.chester.ac.uk/_layouts/listfeed.aspx?List=%7B90300E78%2D1E7F%2D468D%2D923E%2D23F2E0C686E0%7D&Source=https%3A%2F%2Fportal%2Echester%2Eac%2Euk%2FLists%2FNews%2FAllItems%2Easpx",UriKind.Absolute)));
XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);
XmlNodeList selectedNodes = xmlDoc.SelectNodes("/rss/channel/item", nsMgr);
foreach (XmlNode selectedNode in selectedNodes)
{
// and here is where i am stuck
I started to try this but cant figure out what code should be to get at each of the above five elements within each node to supply to my constructor!
newsList.Add(new rssnews(){ title = selectedNode});
}
any help would be amazing!!
This post has been edited by insertAlias: 18 February 2011 - 03:43 PM

New Topic/Question
Reply




MultiQuote






|