libdominator 1.1.2

A HTML Parser Library

To use this package, put the following dependency into your project's dependencies section:


#libdominator libdominator is a xHTML parser library written in d


/// basic example
unittest {
    const string html =
        <p>Here comes a list!</p>
            <li class="wanted">one</li>
            <!-- <li>two</li> -->
            <li class="wanted hard">three</li>
            <li id="item-4">four</li>
            <li checked>five</li>
            <li id="item-6">six</li>
        <p>another list</p>
        <p>have a nice day</p>
    Dominator dom = new Dominator(html);

    foreach(node ; dom.filterDom("")) {
        //do something more usefull with the node then:
        assert(node.getParent.getTag() == "ul");

    Node[] nodes = dom.filterDom("");
    assert(dom.getInner( nodes[0] ) == "one" );
    assert(nodes[0].getAttributes() == [ Attribute("class","wanted") ] );

    assert(dom.filterDom("").length == 6);
    assert(dom.filterDom("").filterComments.length == 5);
    assert(dom.filterDom("li").length == 9);
    assert(dom.filterDom("li[1]").length == 1); //the first li in the dom
    assert(dom.filterDom("*.li[1]").length == 2); //the first li in ul and first li in ol
    assert(dom.getInner( (*dom.filterDom("*{checked:}").ptr) ) == "five");


#Filter Syntax Expression = TAG[PICK]{ATTRNAME:ATTRVALUE} Multiple expressions can be concatenated with "." to find stuff inside of specific parent nodes.

TAGThe Name of the nodea , p , div , *
[PICK](can be ommited) Picks only the n th match. n begins on 1. PICK can be a list or range[1] picks the first match , [1,3] picks the first and third , [1..3] picks the first three matches
{ATTRNAME:ATTRVALUE}The attribute selector{id:myID} , {class:someClass} , {href:(regex)^http://}

Or check out

Authors:Martin Brzenska

Dependencies: none

1.1.2 2016-Dec-04
1.1.1 2016-Nov-22
1.1.0 2016-Nov-20
1.0.6 2016-Nov-12
1.0.5 2016-Nov-06
Show all 14 versions

statistics are temporarily disabled.