Ellen Hu

Ellen Hu

  • NA
  • 63
  • 0

Get Data from XML file

Jan 6 2010 10:38 AM
Hi All,

I need to get data from a giving URL, those data is a XML file.

Here is the part of my code, it works for one URL, but not for another. I could not figure out why it happens.

I need get data from http://feeds.idealist.org/xml/yourCause.xml. Every time the code skipped the yellow highlighted part and went to "catch" section. I had tried to remove "&",  still have no lucky.


It works fine with another link http://www.allforgood.org/api/volopps?output=rss&key=yourcause.  

 


 

try

                {

                    XmlDocument doc = new XmlDocument();

                    rdr = new XmlTextReader("http://feeds.idealist.org/xml/yourCause.xml");

                   

                    if (rdr == null)

                    {

                        return projects;

                    }

            

                    doc.Load(rdr);

                    XmlNodeList listAll = doc.SelectNodes("//VolunteerOpportunities/VolunteerOpportunity");

 

                                                if (listAll != null)

                  {

                       // Do Something

                  }

            }

catch (Exception)

                {

                                        return null;

 

                }

                finally

                {

                    if (rdr != null)

                    {

                        rdr.Close();

                    }

}

 

Thank you,
ellen

Answers (4)