Simple package for query HTML/XML elements using a CSS3 or jQuery-like selector syntax for Nim.
This project is in alpha stage, some features are not supported yet.
- Type selectors
- Class selectors
- ID selectors
- Descendant combinator
- Universal selector
- Attribute selectors
- Child combinator
- Adjacent sibling combinator
- General sibling combinator
- Structural pseudo-classes
$ nimble install q
0.0.2 - supports sibling combinators and multiple class, attributes selectors
0.0.1 - initial release
import q
import xmltree
var html = """<html>
<head>
<tile>Example</title>
</head>
<body>
<nav>
<ul class="menu">
<li class="dropdown">
<a href="#">Link 1</a>
</li>
<li>
<a href="#">Link 2</a>
</li>
</ul>
</nav
</body>
</html>"""
# Parse HTML document
var doc = q(html)
# Search for nodes by css selector
echo doc.select("nav ul.menu li a")
# @[<a href="#">Link 1</a>, <a href="#">Link 2</a>]