Fizzler and QuerySelectorAll

c# html-agility-pack

Question

I've found Fizzler as html parser and jQuery like selector . But seems visual studio can not resolve QuerySelectorAll method.

here is my code :

using HtmlAgilityPack;
HtmlAgilityPack.HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument document = web.Load(url);
var c = document.QuerySelectorAll('div');

did I miss any references ?

EDIT : after some search I found this code for using Fizzler

HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
const string search = "td";
SelectorGenerator<HtmlNode> selectorGenerator1 = new SelectorGenerator<HtmlNode>(new HtmlNodeOps());
HumanReadableSelectorGenerator selectorGenerator2 = new HumanReadableSelectorGenerator();
Parser.Parse(search, new SelectorGeneratorTee(selectorGenerator1, selectorGenerator2));
var c =  selectorGenerator1.Selector(Enumerable.Repeat(doc.DocumentNode, 1)).ToList();

I'm still looking for find good answer for my question.

Popular Answer

Probably this:

using Fizzler.Systems.HtmlAgilityPack;

Also give a shot to CsQuery, my C# jQuery port: https://github.com/jamietre/CsQuery

var dom = CQ.CreateFromUrl(url);
var c = dom["div"];

.. plus everything you're used to from jQuery.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why