2
I wrote a code to read RSS feed that works well. If you access this URL will see that returns an XML in the browser, but when running in my code generates an internal error on the server and do not understand the reason. Someone can help me?
The code below is in dotNetFeedle. If uncomment the second link and comment the first you may see the error.
using System;
using System.Xml;
public class Program
{
public static void Main()
{
string urlXml = "http://g1.globo.com/dynamo/tecnologia/rss2.xml";
//string urlXml = @"http://migalhas.com.br/rss/rss.xml";
//Cria novo documento XML local
XmlDocument doc = new XmlDocument();
//Tenta Carregar XML remoto em nosso XML local
try
{
doc.Load(urlXml);
XmlNodeList rssItems = doc.SelectNodes("//item");
int i = 0;
foreach (XmlNode node in rssItems)
{
i++;
Console.WriteLine(i + " - " + node["title"].InnerText);
if(i==5)
break;
}
}
catch (Exception ex)
{
Console.WriteLine("Erro:" + ex.Message);
}
//Selcecionar nós desejados usando xPath
}
}
It worked. Thank you very much
– Eduardo Sobrinho
@Eduardonephew Wonder, don’t forget to mark as answered :)
– Thiago Loureiro
Thiago, this is the first question answered here. I clicked on a 'checked' sign on the left side of your answer. Is this just to mark as answered? Again, thank you.
– Eduardo Sobrinho
@Eduardonephew is right! That’s right, welcome to Stackoverflow!
– Thiago Loureiro