0

I am using this code to load xml into a doc from a url:

var doc = new XmlDocument();
doc.Load(url);

but this fails due to poorly formed xml.

My question is, how do I obtain the xml being returned so that I can debug the cause?

This is not a duplicate. It is completely differen to the duplicate answer given. I need to get the raw data returned from the url but cannot because it is not correct xml.

SSED
  • 475
  • 3
  • 9
  • 22
  • 1
    can't you hit url directly and read the xml, or use fiddler if need special http headers? – A.T. Oct 11 '17 at 15:19
  • Try calling the api directly and getting the result: https://stackoverflow.com/q/9620278/616304 – Stephen Wilson Oct 11 '17 at 15:19
  • what is the url? – Amit Kumar Singh Oct 11 '17 at 15:20
  • 1
    The classes used to retrieve data from a URL are HttpClient and HttpWebRequest. `XmlDocument` uses HttpWebRequest to get the string and parse it. A simple call to [HttpClient.GetStringAsync()](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.getstringasync?view=netframework-4.7) will return the URL's content as a string – Panagiotis Kanavos Oct 11 '17 at 15:27
  • can't hit api directly as api is behind firewall and need to access via specific ip (which can only currently do via code). will try HttpClient.GetStringAsync() – SSED Oct 11 '17 at 15:33

0 Answers0