I'm new(er) to C#, but I have a background with Java and VB.NET, so jumping in was easy. This weekend I started a new mini-project with C# and a public XML feed from the interwebs. But I'm having a problem loading the XML. Here's my code:
string url = ... ;
...
XmlDocument xmlDoc = new XmlDocument();
...
try{
xmlDoc.Load(url);
}catch(Exception e){
Console.WriteLine(e);
}
When I attempt to load the XML, it throws an exception:
https://i.stack.imgur.com/Xo2Ra.png (Newbies can't attach pictures, sorry)
I wasn't at all surprised when my code didn't work. I started the standard troubleshooting process by figuring out where the problem was. I fully expected my code to be faulty. To test this theory, I found a random XML feed on the web and copied it into my code. To my surprise, it loaded just fine. Now my suspicion shifted to the target XML. It works fine in Chrome and FireFox (loads in .734 seconds), does not require any credentials (open to public), and is valid/well formed.
Then I remembered a JavaScript that I had written a few months ago that uses this same feed. I fired that up, and found it to also be working perfectly.
I'm at a loss here because both my code and XML seem to be fine. Does anyone know how this can be fixed? Do I need to use a HttpWebRequest and pass to the XmlDocument (I don't know how to do this)? Are there any more ways to troubleshoot this?