I have to consume a feed XML (RSS) in my Windows Phone 7 application and display those information in a ListBox.
Following way I tried to read the content in XML feed:
private void button1_Click(object sender, RoutedEventArgs e)
{
client.DownloadStringAsync(new Uri("http://earthquake.usgs.gov/eqcenter/recenteqsww/catalogs/eqs7day-M2.5.xml"), "usgs");
}
Can someone please guide me how to proceed to get the XML info and to display them as ListBox items?
You have to do two things:
The following code shows how to do it:
(
GetFeeddoes part 1,handleFeeddoes part 2,button1_Clickis the click handler which starts the feed download when the user clicks a button.)Most error checking is omitted for brevity. Some information about what XML elements to expect has Wikipedia. The code for downloading the XML file is based on this excellent blog post about using
HttpWebRequest.