XML::LibXML::jQuery - Fast, jQuery-like DOM manipulation over XML::LibXML
use XML::LibXML::jQuery;
my $div = j(<<HTML);
<div>
<h1>Hello World</h1>
<p> ... </p>
<p> ... </p>
</div>
HTML
$div->find('h1')->text; # Hello World
$div->find('p')->size; # 2
XML::LibXML::jQuery is a jQuery-like DOM manipulation module build on top of
XML::LibXML for speed. The goal is to be as fast as possible, and as compatible
as possible with the javascript version of jQuery. Unlike similar modules,
web fetching functionality like -
append($url)> was intentionally not implemented.
Following is a list of similar CPAN modules.
-
Web::Query::LibXML
Web::Query::LibXML is my previous attempt to create a fast, jQuery-like module. But since it uses HTML::TreeBuilder::LibXML (for compatibility with Web::Query) for the underlying DOM system, its not as fast as if it used XML::LibXML directly. Also, maintaining it was a bit of a pain because of the API contracts to Web::Query and HTML::TreeBuilder.
-
jQuery
jQuery seemed to be the perfect candidade for me to use/contribute since its a jQuery port implemented directly over XML::LibXML, but discarded the idea after finding some issues. It was slower than Web::Query::LibXML for some methods, it has its own css selector engine (whose code was a bit scary, I'd rather just use HTML::Selector::XPath), invalid html output (spits xml) and even some broken methods. Which obviously could be fixed, but honestly I didn't find its codebase fun to work on.
-
Web::Query
Web::Query uses the pure perl DOM implementation HTML::TreeBuilder, so its slow.
-
pQuery
pQuery is also built on top of HTML::TreeBuilder, so..
Parses a HTML source and returns a new XML::LibXML::jQuery instance.
A shortcut to new.
Unless otherwise noted, all methods behave exactly like the javascript version.
Implemented signatures:
Documentation and examples at http://api.jquery.com/add/.
Implemented signatures:
- add_class(className)
- add_class(function)
Documentation and examples at http://api.jquery.com/addClass/.
Implemented signatures:
- after(content[, content])
- after(function)
Documentation and examples at http://api.jquery.com/after/.
Implemented signatures:
- data(key, value)
- data(key)
- data(obj)
Documentation and examples at http://api.jquery.com/data/.
Implemented signatures:
-
insert_after(target)
All targets supported: selector, element, array of elements, HTML string, or jQuery object.
Documentation and examples at http://api.jquery.com/insertAfter/.
Like "find", but uses a xpath expression instead of css selector.
Like "filter", but uses a xpath expression instead of css selector.
Copyright (C) Carlos Fernando Avila Gratz.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Carlos Fernando Avila Gratz <cafe@kreato.com.br>