Skip to content

Latest commit

 

History

History
70 lines (52 loc) · 2.1 KB

README.md

File metadata and controls

70 lines (52 loc) · 2.1 KB

Fizzler: .NET CSS Selector Engine

Build Status NuGet MyGet

Fizzler is a .NET Standard 1.0 library; it is a W3C Selectors (Level 3) parser and generic selector framework over document hierarchies.

The default implementation is based on HTMLAgilityPack and selects from HTML documents. The unit tests are based on the jQuery selector engine tests.

Contributions are welcome in forms of:

  • Increased selector support
  • Implementation over an HTML-like hierarchical document model
  • Re-factorings
  • Improved tests

Examples

The following example uses Fizzler.Systems.HtmlAgilityPack:

// Load the document using HTMLAgilityPack as normal
var html = new HtmlDocument();
html.LoadHtml(@"
  <html>
      <head></head>
      <body>
        <div>
          <p class='content'>Fizzler</p>
          <p>CSS Selector Engine</p></div>
      </body>
  </html>");

// Fizzler for HtmlAgilityPack is implemented as the
// QuerySelectorAll extension method on HtmlNode

var document = html.DocumentNode;

// yields: [<p class="content">Fizzler</p>]
document.QuerySelectorAll(".content");

// yields: [<p class="content">Fizzler</p>,<p>CSS Selector Engine</p>]
document.QuerySelectorAll("p");

// yields empty sequence
document.QuerySelectorAll("body>p");

// yields [<p class="content">Fizzler</p>,<p>CSS Selector Engine</p>]
document.QuerySelectorAll("body p");

// yields [<p class="content">Fizzler</p>]
document.QuerySelectorAll("p:first-child");