Answer the question
In order to leave comments, you need to log in
Is it OK to write an HTTP request to read RSS?
Hello. I'm writing an RSS reader and I have a couple of questions. The code is like this:
public static List<NewsRSS> ReadRSS(string Url)
{
List<NewsRSS> News = new List<NewsRSS>();
try
{
WebRequest request = WebRequest.Create(Url);
XmlTextReader NewsXmlReader = new XmlTextReader(request.GetResponse().GetResponseStream());
XDocument NewsXml = XDocument.Load(NewsXmlReader);
foreach (XElement NewsNode in NewsXml.Element("rss").Element("channel").Elements("item"))
{
//тут просто выбираем нужные данные из XML
}
} catch (XmlException XmlErr)
{
Console.WriteLine("Ошибка при работе с XML: {0}", XmlErr.Message);
} catch (HttpListenerException HttpErr )
{
Console.WriteLine("Ошибка при обработке запроса: {0}", HttpErr.Message);
}
return News;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question