line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::Query::LibXML; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOKUHIROM'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
$Web::Query::LibXML::VERSION = '0.39'; |
5
|
|
|
|
|
|
|
|
6
|
40
|
|
|
40
|
|
97550
|
use 5.008005; |
|
40
|
|
|
|
|
171
|
|
7
|
40
|
|
|
40
|
|
256
|
use strict; |
|
40
|
|
|
|
|
76
|
|
|
40
|
|
|
|
|
941
|
|
8
|
40
|
|
|
40
|
|
190
|
use warnings; |
|
40
|
|
|
|
|
71
|
|
|
40
|
|
|
|
|
1311
|
|
9
|
40
|
|
|
40
|
|
225
|
use parent qw/Web::Query Exporter/; |
|
40
|
|
|
|
|
129
|
|
|
40
|
|
|
|
|
303
|
|
10
|
40
|
|
|
40
|
|
22098
|
use HTML::TreeBuilder::LibXML; |
|
40
|
|
|
|
|
2502061
|
|
|
40
|
|
|
|
|
1746
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
40
|
|
|
40
|
|
341
|
use XML::LibXML 2.0107; |
|
40
|
|
|
|
|
265
|
|
|
40
|
|
|
|
|
1750
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw/wq/; |
16
|
|
|
|
|
|
|
|
17
|
88
|
|
|
88
|
1
|
119966
|
sub wq { Web::Query::LibXML->new(@_) } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _build_tree { |
20
|
117
|
|
|
117
|
|
447
|
my $tree = HTML::TreeBuilder::LibXML->new(); |
21
|
117
|
|
|
|
|
941
|
$tree->ignore_unknown(0); |
22
|
117
|
|
|
|
|
470
|
$tree->store_comments(1); |
23
|
117
|
|
|
|
|
395
|
$tree; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _is_same_node { |
27
|
22
|
|
|
22
|
|
113
|
$_[1]->{node}->isSameNode($_[2]->{node}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub prev { |
31
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
32
|
1
|
|
|
|
|
1
|
my @new; |
33
|
1
|
|
|
|
|
2
|
for my $tree (@{$self->{trees}}) { |
|
1
|
|
|
|
|
4
|
|
34
|
2
|
|
|
|
|
33
|
push @new, $tree->left; |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
33
|
|
|
25
|
return (ref $self || $self)->new_from_element(\@new, $self); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub next { |
40
|
22
|
|
|
22
|
1
|
36
|
my $self = shift; |
41
|
22
|
|
|
|
|
33
|
my @new; |
42
|
22
|
|
|
|
|
26
|
for my $tree (@{$self->{trees}}) { |
|
22
|
|
|
|
|
47
|
|
43
|
29
|
|
|
|
|
76
|
push @new, grep { $_ } $tree->right; |
|
29
|
|
|
|
|
641
|
|
44
|
|
|
|
|
|
|
} |
45
|
22
|
|
33
|
|
|
88
|
return (ref $self || $self)->new_from_element(\@new, $self); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub tagname { |
49
|
16
|
|
|
16
|
1
|
45
|
my $self = shift; |
50
|
16
|
100
|
|
|
|
38
|
my $method = @_ ? 'setNodeName' : 'nodeName'; |
51
|
|
|
|
|
|
|
|
52
|
16
|
|
|
|
|
20
|
my @retval = map { $_->{node}->$method(@_) } @{$self->{trees}}; |
|
16
|
|
|
|
|
103
|
|
|
16
|
|
|
|
|
28
|
|
53
|
16
|
50
|
|
|
|
86
|
return wantarray ? @retval : $retval[0]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
139
|
|
|
139
|
|
604
|
sub _node_id { $_[1]{node}->unique_key } |
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding utf-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Web::Query::LibXML - fast, drop-in replacement for Web::Query |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version 0.39 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SYNOPSIS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
use Web::Query::LibXML; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# imports wq() |
78
|
|
|
|
|
|
|
# all methods inherited from Web::Query |
79
|
|
|
|
|
|
|
# see Web::Query for documentation |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Web::Query::LibXML is Web::Query subclass that overrides the _build_tree() method to use HTML::TreeBuilder::LibXML instead of HTML::TreeBuilder::XPath. |
84
|
|
|
|
|
|
|
Its a lot faster than its superclass. Use this module unless you can't install (or depend on) L<XML::LibXML> on your system. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 FUNCTIONS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over 4 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item C<< wq($stuff) >> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is a shortcut for C<< Web::Query::LibXML->new($stuff) >>. This function is exported by default. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 METHODS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
All public methods are inherited from L<Web::Query>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright (C) Carlos Fernando Avila Gratz. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
105
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Carlos Fernando Avila Gratz E<lt>cafe@q1software.comE<gt> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SEE ALSO |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L<Web::Query>, L<HTML::TreeBuilder::LibXML>, L<XML::LibXML> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 BUGS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
118
|
|
|
|
|
|
|
https://github.com/tokuhirom/Web-Query/issues |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
121
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
122
|
|
|
|
|
|
|
feature. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|