|
| 1 | +[](https://travis-ci.org/cafe01/xml-libxml-jquery) |
1 | 2 | # NAME
|
2 | 3 |
|
3 |
| -XML::LibXML::jQuery - It's new $module |
| 4 | +XML::LibXML::jQuery - Fast, jQuery-like DOM manipulation over XML::LibXML |
4 | 5 |
|
5 | 6 | # SYNOPSIS
|
6 | 7 |
|
7 | 8 | use XML::LibXML::jQuery;
|
8 | 9 |
|
| 10 | + my $div = j(<<HTML); |
| 11 | + <div> |
| 12 | + <h1>Hello World</h1> |
| 13 | + <p> ... </p> |
| 14 | + <p> ... </p> |
| 15 | + </div> |
| 16 | + HTML |
| 17 | + |
| 18 | + $div->find('h1')->text; # Hello World |
| 19 | + |
| 20 | + $div->find('p')->size; # 2 |
| 21 | + |
9 | 22 | # DESCRIPTION
|
10 | 23 |
|
11 |
| -XML::LibXML::jQuery is ... |
| 24 | +XML::LibXML::jQuery is a jQuery-like DOM manipulation module build on top of |
| 25 | +[XML::LibXML](https://metacpan.org/pod/XML::LibXML) for speed. The goal is to be as fast as possible, and as compatible |
| 26 | +as possible with the javascript version of jQuery. Unlike similar modules, |
| 27 | +web fetching functionality like `-`append($url)> was intentionally not implemented. |
| 28 | + |
| 29 | +# SIMILAR MODULES |
| 30 | + |
| 31 | +Following is a list of similar CPAN modules. |
| 32 | + |
| 33 | +- Web::Query::LibXML |
| 34 | + |
| 35 | + [Web::Query::LibXML](https://metacpan.org/pod/Web::Query::LibXML) is my previous attempt to create a fast, jQuery-like module. |
| 36 | + But since it uses [HTML::TreeBuilder::LibXML](https://metacpan.org/pod/HTML::TreeBuilder::LibXML) (for compatibility with [Web::Query](https://metacpan.org/pod/Web::Query)) |
| 37 | + for the underlying DOM system, its not as fast as if it used XML::LibXML directly. |
| 38 | + Also, maintaining it was a bit of a pain because of the API contracts to [Web::Query](https://metacpan.org/pod/Web::Query) |
| 39 | + and [HTML::TreeBuilder](https://metacpan.org/pod/HTML::TreeBuilder). |
| 40 | + |
| 41 | +- jQuery |
| 42 | + |
| 43 | + [jQuery](https://metacpan.org/pod/jQuery) seemed to be the perfect candidade for me to use/contribute since its |
| 44 | + a jQuery port implemented directly over XML::LibXML, but discarded the idea after |
| 45 | + finding some issues. It was slower than Web::Query::LibXML for some methods, it |
| 46 | + has its own css selector engine (whose code was a bit scary, I'd rather just |
| 47 | + use HTML::Selector::XPath), invalid html output (spits xml) and even some broken |
| 48 | + methods. Which obviously could be fixed, but honestly I didn't find its codebase |
| 49 | + fun to work on. |
| 50 | + |
| 51 | +- Web::Query |
| 52 | + |
| 53 | + [Web::Query](https://metacpan.org/pod/Web::Query) uses the pure perl DOM implementation [HTML::TreeBuilder](https://metacpan.org/pod/HTML::TreeBuilder), so its |
| 54 | + slow. |
| 55 | + |
| 56 | +- pQuery |
| 57 | + |
| 58 | + [pQuery](https://metacpan.org/pod/pQuery) is also built on top of [HTML::TreeBuilder](https://metacpan.org/pod/HTML::TreeBuilder), so.. |
| 59 | + |
| 60 | +# CONSTRUCTOR |
| 61 | + |
| 62 | +## new |
| 63 | + |
| 64 | +Parses a HTML source and returns a new [XML::LibXML::jQuery](https://metacpan.org/pod/XML::LibXML::jQuery) instance. |
| 65 | + |
| 66 | +# EXPORTED FUNCTION |
| 67 | + |
| 68 | +## j |
| 69 | + |
| 70 | +A shortcut to [new](https://metacpan.org/pod/new). |
| 71 | + |
| 72 | +# METHODS |
| 73 | + |
| 74 | +Unless otherwise noted, all methods behave exactly like the javascript version. |
| 75 | + |
| 76 | +## add |
| 77 | + |
| 78 | +## add\_class |
| 79 | + |
| 80 | +## after |
| 81 | + |
| 82 | +## append |
| 83 | + |
| 84 | +## append\_to |
| 85 | + |
| 86 | +## as\_html |
| 87 | + |
| 88 | +## attr |
| 89 | + |
| 90 | +## before |
| 91 | + |
| 92 | +## children |
| 93 | + |
| 94 | +## clone |
| 95 | + |
| 96 | +## contents |
| 97 | + |
| 98 | +## data |
| 99 | + |
| 100 | +## detach |
| 101 | + |
| 102 | +## document |
| 103 | + |
| 104 | +## each |
| 105 | + |
| 106 | +## eq |
| 107 | + |
| 108 | +## end |
| 109 | + |
| 110 | +## find |
| 111 | + |
| 112 | +## get |
| 113 | + |
| 114 | +## html |
| 115 | + |
| 116 | +## insert\_after |
| 117 | + |
| 118 | +## insert\_before |
| 119 | + |
| 120 | +## filter |
| 121 | + |
| 122 | +## first |
| 123 | + |
| 124 | +## last |
| 125 | + |
| 126 | +## parent |
| 127 | + |
| 128 | +## prepend |
| 129 | + |
| 130 | +## prepend\_to |
| 131 | + |
| 132 | +## remove |
| 133 | + |
| 134 | +## remove\_attr |
| 135 | + |
| 136 | +## remove\_class |
| 137 | + |
| 138 | +## replace\_with |
| 139 | + |
| 140 | +## serialize |
| 141 | + |
| 142 | +## size |
| 143 | + |
| 144 | +## tagname |
| 145 | + |
| 146 | +## text |
| 147 | + |
| 148 | +## xfind |
| 149 | + |
| 150 | +Like ["find"](#find), but uses a xpath expression instead of css selector. |
| 151 | + |
| 152 | +## xfilter |
| 153 | + |
| 154 | +Like ["filter"](#filter), but uses a xpath expression instead of css selector. |
12 | 155 |
|
13 | 156 | # LICENSE
|
14 | 157 |
|
|
0 commit comments