Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6703943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:13:53+00:00 2026-05-26T07:13:53+00:00

I’m new(er) to C#, but I have a background with Java and VB.NET, so

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:13:54+00:00Added an answer on May 26, 2026 at 7:13 am

    As i indicated in my comment, XmlDocument.Load is farely primitive compared to a full blown request from a browser. When you use a proxy- or packet tracer like Fiddler, you will find that for example IE9 makes a request including specific headers:

    GET
    http://stats.us.playstation.com/warhawk/XmlFeedAction.action?start=1&end=1
    HTTP/1.1 Accept: text/html, application/xhtml+xml, /
    Accept-Language: en-US User-Agent: Mozilla/5.0 (compatible; MSIE 9.0;
    Windows NT 6.1; Trident/5.0) Accept-Encoding: gzip, deflate
    Connection: Keep-Alive Host: stats.us.playstation.com Cookie:
    JSESSIONID=HLygTblTG13HhXqqw80jw9Wdhw0q03dxcQLp04fD3Q5yChYvPGn6!-882698034;
    SONYCOOKIE1=543467712.20480.0000

    Now the webserver’s behavior is subjected to the headers specified in a request. In this case, the Accept and user-agent play a role. I can succesfully load the xml content in a XmlDocument by including some fake headers like the following:

            string url = "http://stats.us.playstation.com/warhawk/XmlFeedAction.action?start=1&end=1";
    
            WebClient client = new WebClient();
            client.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1";
            client.Headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            string data = client.DownloadString(url);
    
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.