Ho un problema, quando provo a caricare il file dal filesystem. Problema che nel valore di alcuni controlli HTML ho meno del segno "<" all'interno del valore di span
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();
Non dovresti avere simboli come <
come contenuto nel tuo HTML. Averli nel tuo html rende l'html non valido e farà sì che il pacchetto HTMLAgility non funzioni correttamente.
Se ne hai bisogno nel tuo html devi codificarli. <
diventa %lt;
vedere qui http://www.w3schools.com/html/html_entities.asp