Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/atifaziz/Fizzler

.NET CSS Selector Engine
https://github.com/atifaziz/Fizzler

css

Last synced: 3 months ago
JSON representation

.NET CSS Selector Engine

Awesome Lists containing this project

README

        

# Fizzler: .NET CSS Selector Engine

[![Build Status][build-badge]][builds]
[![NuGet][nuget-badge]][nuget-pkg]
[![MyGet][myget-badge]][edge-pkgs]

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

The [default implementation][fizzhap] is based on [HTMLAgilityPack][hap] 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][fizzhap]:

```c#
// Load the document using HTMLAgilityPack as normal
var html = new HtmlDocument();
html.LoadHtml(@"




Fizzler


CSS Selector Engine




");

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

var document = html.DocumentNode;

// yields: [

Fizzler

]
document.QuerySelectorAll(".content");

// yields: [

Fizzler

,

CSS Selector Engine

]
document.QuerySelectorAll("p");

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

// yields [

Fizzler

,

CSS Selector Engine

]
document.QuerySelectorAll("body p");

// yields [

Fizzler

]
document.QuerySelectorAll("p:first-child");
```

[build-badge]: https://img.shields.io/appveyor/ci/raboof/fizzler/master.svg?label=windows
[builds]: https://ci.appveyor.com/project/raboof/fizzler
[myget-badge]: https://img.shields.io/myget/raboof/vpre/Fizzler.svg?label=myget
[edge-pkgs]: https://www.myget.org/feed/raboof/package/nuget/Fizzler
[nuget-badge]: https://img.shields.io/nuget/v/Fizzler.svg
[nuget-pkg]: https://www.nuget.org/packages/Fizzler

[w3cs3]: https://www.w3.org/TR/selectors-3/
[fizzhap]: http://www.nuget.org/packages/Fizzler.Systems.HtmlAgilityPack/
[hap]: http://html-agility-pack.net/