XmlDocument.LoadXml () throws a ComException

I am trying to parse an XML document returned from this link , but I am getting an exception of type ComException with the following message:

Error HRESULT E_FAIL has been returned from a call to a COM component.

Here is the code:

  try { //... string EPGXML = await DownloadAsync(url); var xmldoc = new XmlDocument(); xmldoc.LoadXml(EPGXML); //this line throws the exception //...rest of the code } catch (Exception) { //I get here... } 

Could you please help me why I get this message and how can I fix it? Thank.

EDIT:

I am reading the XML source using this function (maybe I'm wrong here, and I have to do something to get the string in UTF-8, because I do not see German characters in the string in debug mode (viewport):

  private async static Task<string> DownloadPageAsync(string url) { try { HttpClientHandler handler = new HttpClientHandler(); handler.UseDefaultCredentials = true; handler.AllowAutoRedirect = true; handler.UseCookies = true; HttpClient client = new HttpClient(handler); client.MaxResponseContentBufferSize = 10000000; HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); string responseBody = response.Content.ReadAsString(); return responseBody; } catch (Exception ex) { return "error" + ex.Message; } } 
+2
c # xml windows-runtime
Nov 30 2018-11-11T00:
source share
2 answers

The XML you submitted is not valid, at least what Firefox says:

Erreur d'analysis XML: mal formé Location: http://www.onlinetvrecorder.com/?aktion=epg_export&format=xml&btn_ok=OK& > station = 3SAT, ANIXE, ARD & from = 11/30/2011 & to = 11/30/2011 Numéro de ligne 218, Colonne 193:

(Sorry for the french)

Look a little closer, it looks like the parser is broken into the word "Plötzlich" by the symbol "ö".

Use CDATA to prevent this.

 <![CDATA[Your text here can contain special chars]]> 
+7
Nov 30 '11 at 18:07
source share

Do not try to load an XML document using an html page. Use the Html Agility Pack that was supposed to do this.

EDIT . If you just want the page source to be a string, this should do the trick.

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://stackoverflow.com/posts/8331002"); request.Method = "GET"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string data = string.Empty; using (StreamReader reader = new StreamReader(response.GetResponseStream())) data = reader.ReadToEnd(); Console.WriteLine(data); 
+3
Nov 30 '11 at 18:30
source share