HTML::TreeBuilder::LibXML(3pm)

HTML::TreeBuilder::LibXML3pm

Html::treebuilder and xpath compatible interface with libxml

Usage

    use HTML::TreeBuilder::LibXML;
    my $tree = HTML::TreeBuilder::LibXML->new;
    $tree->parse($html);
    $tree->eof;
    # $tree and $node compatible to HTML::Element
    my @nodes = $tree->findvalue($xpath);
    for my $node (@nodes) {
        print $node->tag;
        my %attr = $node->all_external_attr;
    }
    HTML::TreeBuilder::LibXML->replace_original(); # replace HTML::TreeBuilder::XPath->new

Overview

HTML::TreeBuilder::XPath is libxml based compatible interface to HTML::TreeBuilder, which could be slow for a large document.

HTML::TreeBuilder::LibXML is drop-in-replacement for HTML::TreeBuilder::XPath.

This module doesn't implement all of HTML::TreeBuilder and HTML::Element APIs, but enough methods are defined so modules like Web::Scraper work.

Benchmark

This is a benchmark result by tools/benchmark.pl

        Web::Scraper: 0.26
        HTML::TreeBuilder::XPath: 0.09
        HTML::TreeBuilder::LibXML: 0.01_01
                     Rate  no_libxml use_libxml
        no_libxml  5.45/s         --       -94%
        use_libxml 94.3/s      1632%         --

Thanks to

woremacx++ http://d.hatena.ne.jp/woremacx/20080202/1201927162

id:dailyflower

Releases

7 releases since Debian 7 (Wheezy); the text changed 5 times.

  1. 7
  2. 8
  3. 9
  4. 10–11
  5. 12
  6. 13

Author

Tokuhiro Matsuno <[email protected]>

Tatsuhiko Miyagawa <[email protected]>

Masahiro Chiba

License

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

From libhtml-treebuilder-libxml-perl 0.28-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.