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)
{
}
}
catch (Exception)
{
return null;
}
finally
{
if (rdr != null)
{
rdr.Close();
}
}
ellen
Sam HobbsPosted Jan 6, 2010, 11:43 AM
Your code is ignoring errors. In the catch block, the program just returns without showing what the error is. You should always show all errors from your program so you can see the errors before posting a question such as this.
The program in the attached zip is a console program that works for me. Note that I am using try/catch blocks for most statements, and I write out the error from each catch block so when there is an error you can see exactly where the error is occuring and the error message. I don't know why this code works for me yet your code does not work for you; I don't think I changed anything that caused my code to work. Perhaps there was a temporary error with that site and if so then the error messages from the error would have helped you dtermine the problem. When a site does not work, try browsing to it in a browser such as IE. You can use a console program such as the one I attached to test code.
paul danielPosted Jan 12, 2010, 8:18 AM
Refer this link
http://mudassarkhan.wordpress.com/2009/01/10/accessing-xml-files-using-adonet/
Sam HobbsPosted Jan 7, 2010, 12:16 PM
Sam HobbsPosted Jan 6, 2010, 11:49 AM
When I go to http://feeds.idealist.org/xml/yourCause.xml (just click on that link) IE says:
"Internet Explorer cannot display this feed"
and
"The size of this feed exceeds the download limit.".