I'm trying to write a RSS Reader that reads data from a remote XML file, the problem is that when I run application for the first time it downloads normally but when I update the information on XML file and run application again it does not download the new items.
I call it on public Main()
WebClient wc = new WebClient();
wc.DownloadStringAsync(new Uri("http://suntvhost.do.am/sunnews.xml"));
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
Handler:
private void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
//This simple test will return an error if the device is not connected to the internet
if (e.Error != null)
return;
XElement xmlitems = XElement.Parse(e.Result);
// We need to create a list of the elements
List<XElement> elements = xmlitems.Descendants("item").ToList();
// Now we're putting the informations that we got in our ListBox in the XAML code
// we have to use a foreach statment to be able to read all the elements
// Description 1 , Link1 , Title1 are the attributes in the RSSItem class that I've already added
List<RSSItem> aux = new List<RSSItem>();
foreach (XElement rssItem in elements)
{
RSSItem rss = new RSSItem();
rss.Description1 = rssItem.Element("description").Value;
rss.Link1 = rssItem.Element("link").Value;
rss.Title1 = rssItem.Element("title").Value;
rss.Date1 = rssItem.Element("pubDate").Value;
aux.Add(rss);
TextBlock tbTitle = new TextBlock();
tbTitle.Text = "\n" + rss.Title1;
ListBoxRss.Items.Add(tbTitle);
// and so on for the rest of items...
}
}