G
Guest
Hi,
I'm using WebClient to download a XML file from a remote server. I then save
the xml into a string.
The problem is when i use XmlDocument LoadXml() on that string. I get the
following exception:
"System.Xml.XmlException was unhandled
Message="Data at the root level is invalid. Line 1, position 1."
If i save the xml file (on the remote server) as ASCII file then there is no
problem. For some reason, the LoadXml() function cannot handle the utf8 file
format! Of course my xml is declared as encoding="utf-8".
This is my code:
string link = "http://myServer/Test.xml";
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.UTF8;
string test = client.DownloadString(link);
client.Dispose();
XmlDocument testXML = new XmlDocument();
testXML.LoadXml(test); // <-- Here i get the exception
I'll appreciate your help
10x
I'm using WebClient to download a XML file from a remote server. I then save
the xml into a string.
The problem is when i use XmlDocument LoadXml() on that string. I get the
following exception:
"System.Xml.XmlException was unhandled
Message="Data at the root level is invalid. Line 1, position 1."
If i save the xml file (on the remote server) as ASCII file then there is no
problem. For some reason, the LoadXml() function cannot handle the utf8 file
format! Of course my xml is declared as encoding="utf-8".
This is my code:
string link = "http://myServer/Test.xml";
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.UTF8;
string test = client.DownloadString(link);
client.Dispose();
XmlDocument testXML = new XmlDocument();
testXML.LoadXml(test); // <-- Here i get the exception
I'll appreciate your help
10x