0
 public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        try
        {
            DataSet ds = new DataSet();
            ds.ReadXml(@"http://tecnologia.ig.com.br/rss.xml");

            XmlDocument doc = new XmlDocument();
            XmlUrlResolver resolver = new XmlUrlResolver();
            resolver.Credentials = new System.Net.NetworkCredential("bruno", "*****");//intentionally hiding real password from stackoverflow
            doc.XmlResolver = resolver;

            foreach (DataRow dr in ds.Tables["item"].Rows)
            {
                Response.Write("Item TITLE: " + dr["title"].ToString() + "<br />");
                Response.Write("Descrição : " + dr["description"].ToString() + "<br />");
                Response.Write("Data de Publicação: " + dr["pubDate"].ToString() + "<br />");
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
}

I execute the Code, and the system return two error's
1 - A column named 'link' already belongs to this DataTable: cannot set a nested table name to the same name. 2 - The remote server returned an error: (407) Proxy Authentication Required.

Thanks!

alex.b
  • 4,547
  • 1
  • 31
  • 52
Bruno Casali
  • 1,339
  • 2
  • 17
  • 32
  • Likely the first error relates to the second. Take a look here for some info about your settings which may remove the second error, and hopefully the first: http://stackoverflow.com/questions/1524566/407-proxy-authentication-required – stevepkr84 Aug 13 '13 at 12:59

2 Answers2

1

Just provide an idea for reading RSS Feed:

  1. Create a WebRequest and WebReponse object:

    WebRequest request=WebRequest.Create("your url");
    WebReponse response=request.GetRespose();
    
  2. Create a XML document and load the XML document with stream from response object:

    Stream rssStream=response.GetResponseStream();
    XMLDocument xmlDoc=new XMLDocument();
    xmlDoc.Load(rssStream);
    
  3. Retrieve matching XML nodes from XMLDocument with XMLNodeList:

    XmlNodeList xmlNodeList = xmlDoc.SelectNodes("your XPath expression");
    
  4. Now you can loop the RSS feed items to get what you want:

     for (int i = 0; i < xmlNodeList.Count; i++)
        {
            XmlNode xmlNode;
    
            xmlNode = xmlNodeList.Item(i).SelectSingleNode("ProductName");
            //xmlNode.InnerText;
        }
    
Sean Kendle
  • 3,538
  • 1
  • 27
  • 34
Sain Pradeep
  • 3,119
  • 1
  • 22
  • 31
  • This is the kind of suggestion I'd go with, rather than parsing it into a dataset – Daniel Dawes Aug 13 '13 at 13:03
  • System.Net.WebProxy proxy = new System.Net.WebProxy(@"ip:door"); proxy.Credentials = new System.Net.NetworkCredential("User", "Pass"); System.Net.WebRequest.DefaultWebProxy = proxy; I solved the problem 1... and the problem number two it is related to the rss web site (rss/XML corrupted) I just changed the link and it worked, thanks anyway – Bruno Casali Aug 13 '13 at 13:49
0

The 2nd problem:

You probably have a corporate proxy, try using this in the web.config:

<system.net>
  <defaultProxy useDefaultCredentials="true" />
</system.net>

As for the 1st problem:

http://forums.asp.net/t/1220157.aspx/1

The issue is likely because XML will allow duplicate nodes and a data table will not allow duplicate columns, so you cannot parse directly to a data table.

I would suggest doing some research into parsing and using XML data before going to far down the data table route

Daniel Dawes
  • 975
  • 5
  • 16