I want to make an app to show news inside a textbox from an rss feed.. But the problem is rss feed contains and error in it's xml codes. Therefor Syndicationclient class can not be used properly. So I've made my program to get the xml text from the rssfeed and write the rss feed inside a textfile in the Application's local folder..
But the problem is I dont know how to retrieve feed to the Syndication feed from that file.. And here is the code I've tried..
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://lankadeepa.lk/index.php/maincontroller/breakingnews_rss");
request.Method = "GET";
var response = await request.GetResponseAsync();
string data = string.Empty;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
data = await reader.ReadToEndAsync();
textBox1.Text = data.ToString();
textBox1.Text = textBox1.Text.Replace(@"</admin:generatoragent>", @"</admin:generatorAgent>");
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("xmlcodes.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(file, textBox1.Text);
string feedpath = file.Path.ToString();
SyndicationClient client = new SyndicationClient();
SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri(feedpath));
textBox1.Text = "";
foreach (SyndicationItem item in feed.Items)
{
textBox1.Text += item.Title.ToString() + Environment.NewLine + item.Summary.Text.ToString() +
Environment.NewLine + Environment.NewLine;
}
What's the wrong with my code ? or SyndicationFeed class cant retrieve feed from a file ?
PS:
And Im not sure if I corrected the xml error in the feed properly.. Here is the feed.. "http://lankadeepa.lk/index.php/maincontroller/breakingnews_rss"
In the first lines it contains a xml tag like this..
<admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
here hundreds of xml codes and
</admin:generatoragent>
I dont know well about xml. But I would like to know about this too.. In XAML here is how code writes..
<tag> </tag>
or
<tag />
no closing tag..
But in this feed the first tag it contains and then it contains a closing tag too.. It must be wrong. doesnt it ? and the first one is "generatorAgent" and the second one is "generatoragent" the letter A is changed to lowecase letter in the second.. does xml is a case sensitive language ?
PS: And here is the error I got..
An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll but was not handled in user code
Additional information: The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)
User contributions licensed under CC BY-SA 3.0