Abhijeet  Pandey

Abhijeet Pandey

  • NA
  • 62
  • 1.1k

Error while trying to read xml from URL in asp.net core 2.1

Jul 23 2018 9:06 AM
I am trying to read a XML file from a URL and below is my code in .net core
 
var url = "https://some.com/feeds/newfile.xml";
var httpClient = new HttpClient();
var result = httpClient.GetAsync(url).Result;
var stream = result.Content.ReadAsStreamAsync().Result;
var itemXml = XElement.Load(stream);
 
when the deubgger hits at .load , it throws an error "error on line 22 at column 46: xmlParseEntityRef: no name"
 
Below is the snapshot of the XML where error occurs ie line 22
 
<li>Win management’s support for your LOTO & machine guarding initiatives </li> 

Answers (3)