atifaziz / Hazz

CSS Selectors (via Fizzler) for HtmlAgilityPack (HAP)
Other
64 stars 7 forks source link

QuerySelector does not find class names with line breaks #22

Closed shravan2x closed 3 years ago

shravan2x commented 3 years ago

I have to parse and query HTML that's formatted badly with line breaks in class attributes. This library does not appear to support those however:

string html = @"<html><body><div class=""class_1""><span class=""class_2
 class_3"">Text</span></body></html>";
HtmlDocument htmldom = new HtmlDocument();
htmldom.LoadHtml(html);

Console.WriteLine(JsonConvert.SerializeObject(htmldom.DocumentNode.QuerySelector(".class_1").FirstChild.GetClasses())); // Prints classes correctly
Console.WriteLine(htmldom.DocumentNode.QuerySelector(".class_1 > .class_2")); // Prints null

It works fine when the line break is removed.

shravan2x commented 3 years ago

Actually this has been resolved in master way back in April 2020. When will 1.3.0 be out?

atifaziz commented 3 years ago

Duplicate of #15.