tags:

views:

46

answers:

1

I am using XmlDocument to open a remote XML document

string apiURL = Settings.Settings.URLBaseAPI + "user.php";

apiURL = apiURL + "?u=" + Settings.Settings.ForumUsername
       + "&p=" + MD5Tool.GetMD5Hash(Settings.Settings.ForumPassword)
       + "&mode=token";

doc.Load(apiURL);

Is there anyway to set the user agent for the internet access performed to retrieve the XML document?

+3  A: 

When loading through the doc.Load(string) method, this is not possible.

You can try and retrieve the xml with WebClient, which will allow overriding some HTTP headers then use doc.LoadXML(string) to populate your XmlDocument.

Oded
Sounds like that should work - I'll give it a go. Probably should have been using WebClient all along in any case.
BENBUN Coder
If you are retrieving documents via http, using WebClient or one of the other System.Net classes gives you much more control over the connection.
Oded