When I download the XML from this URL and deserialize from hard disk, there's no error. When I'm deserialize from the URL with Streamreader and Webrequest or XmlDocument.Load or XmlTextReader I got every time the error "Data at the root level is invalid. Line 1, position 1 "
I've tried already a lot of possible several ways to read the online XML. I also tried to force the encoding to ISO-8859-1 as given in the XML but without result.
string path = "http://publications.elia.be/Publications/Publications/InternetImbalance.v1.svc/GetImbalanceMeasuresByTime";
var col = new Model.EliaImbalanceMinutes.AllData();
try
{
using (TextReader reader = new StreamReader(WebRequest.Create(path).GetResponse().GetResponseStream(), Encoding.GetEncoding("ISO-8859-1")))
{
XmlSerializer serializer = new XmlSerializer(typeof(Model.EliaImbalanceMinutes.AllData));
col = (Model.EliaImbalanceMinutes.AllData)serializer.Deserialize(reader);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
It gives me this error:
System.InvalidOperationException HResult=0x80131509 Message=Het XML-document (1, 1) bevat een fout.
User contributions licensed under CC BY-SA 3.0