I have a problem, when I trying to load file from filesystem. Issue that in value of some HTML control I have less than sign "<" inside span value
HtmlDocument doc = new HtmlDocument();
doc.OptionReadEncoding = true;
//StreamReader str = new StreamReader(fileName, Encoding.UTF8);
StreamReader str = new StreamReader(@"E:\HTMLS\OEL\1030,1.html",Encoding.UTF8,true);
doc.Load(str.BaseStream, Encoding.ASCII);
//string streamString = str.ReadToEnd().
str.Close();
//all nodes
doc.DocumentNode.Descendants().Where(x => x.Name == "#text" && (x.InnerText == "\r\n\t" || x.InnerText == "\r\n" || x.InnerText == "\r\n\t\t")).ToList().ForEach(x => x.Remove());
List<HtmlNode> listHtmlNode = doc.DocumentNode.Descendants("table").ToList();
span
has a<
character in it. If that's the case, your document is not valid HTML and would not/should not parse correctly - the character should be written as the HTML entity<
instead. – Dan Puzey May 13 '14 at 9:47