atifaziz / Hazz

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

The ":only-child" selector does not capture the HTML element #16

Closed atifaziz closed 4 years ago

atifaziz commented 4 years ago

Code to reproduce (using version 1.2):

using var client = new HttpClient();
var doc = new HtmlDocument();
doc.LoadHtml(await client.GetStringAsync("https://www.example.com/"));
foreach (var e in doc.DocumentNode.QuerySelectorAll(":only-child"))
    Console.WriteLine(e.Name);

It finds only 2 elements:

div
a

whereas using document.querySelectorAll(':only-child') in Chrome finds html in addition to the above two.