Windows Phone 7 : Building Simple RSS Reader

Windows Phone 7 : Building Simple RSS Reader

  • Comments 5

Here we will build simple RSS reader in Windows Phone. Reading RSS is reading XML file online. So you need some engineering between XML and XAML. Here you go.

Your phone UI

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <ListBox Name="lstRSS">
                    <TextBlock Text="{Binding Path=Title}"></TextBlock>
                    <TextBlock Text="{Binding Path=PubDate}"></TextBlock>
                    <TextBlock Text=" "></TextBlock>

Then the class to define the structure

public class RSSClass
    public string Title { get; set; }
    public string PubDate { get; set; }

After that we need few lines to read it online.

public Page1()

    WebClient myRSS = new WebClient();
    myRSS.DownloadStringCompleted += new DownloadStringCompletedEventHandler(myRSS_DownloadStringCompleted);

    //Read Async
    myRSS.DownloadStringAsync(new Uri(@""));

void myRSS_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    //Check if the Network is available
    if (!Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable)
        var rssData = from rss in XElement.Parse(e.Result).Descendants("item")
                        select new RSSClass
                            Title = rss.Element("title").Value,
                            PubDate = rss.Element("pubDate").Value
        lstRSS.ItemsSource = rssData;
        MessageBox.Show("No network is available..");


Leave a Comment
  • Please add 4 and 1 and type the answer here:
  • Post
  • Hi!!!

    I'm using this example but when I try to compile sends me a message that "XElement" doesn't exist


  • Hi, I have used your code and i think there is a bug in line

    if (!Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable)

    IsNetworkAvailable is true if the network is available , so as per your code if network in available the code for fetching the RSS feeds are executed.

  • Error "Xelement", how can i solve this?

  • @Simone - I think we need to have XElement (not Xelement)

  • You need to add refernce for System.Xml.Linq to solve 'XElement' error.

Page 1 of 1 (5 items)