line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::Query::LibXML; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOKUHIROM'; |
3
|
|
|
|
|
|
|
# ABSTRACT: fast, drop-in replacement for Web::Query |
4
|
|
|
|
|
|
|
$Web::Query::LibXML::VERSION = '1.00'; |
5
|
|
|
|
|
|
|
|
6
|
40
|
|
|
40
|
|
102506
|
use 5.008005; |
|
40
|
|
|
|
|
152
|
|
7
|
40
|
|
|
40
|
|
262
|
use strict; |
|
40
|
|
|
|
|
82
|
|
|
40
|
|
|
|
|
964
|
|
8
|
40
|
|
|
40
|
|
244
|
use warnings; |
|
40
|
|
|
|
|
107
|
|
|
40
|
|
|
|
|
1412
|
|
9
|
40
|
|
|
40
|
|
223
|
use parent qw/Web::Query Exporter/; |
|
40
|
|
|
|
|
79
|
|
|
40
|
|
|
|
|
405
|
|
10
|
40
|
|
|
40
|
|
25084
|
use HTML::TreeBuilder::LibXML; |
|
40
|
|
|
|
|
2537397
|
|
|
40
|
|
|
|
|
1921
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# version required for unique_key |
13
|
40
|
|
|
40
|
|
462
|
use XML::LibXML 2.0107; |
|
40
|
|
|
|
|
274
|
|
|
40
|
|
|
|
|
1791
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw/wq/; |
16
|
|
|
|
|
|
|
|
17
|
88
|
|
|
88
|
1
|
122519
|
sub wq { Web::Query::LibXML->new(@_) } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _build_tree { |
20
|
117
|
|
|
117
|
|
438
|
my $tree = HTML::TreeBuilder::LibXML->new(); |
21
|
117
|
|
|
|
|
864
|
$tree->ignore_unknown(0); |
22
|
117
|
|
|
|
|
482
|
$tree->store_comments(1); |
23
|
117
|
|
|
|
|
364
|
$tree; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _is_same_node { |
27
|
22
|
|
|
22
|
|
109
|
$_[1]->{node}->isSameNode($_[2]->{node}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub prev { |
31
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
32
|
1
|
|
|
|
|
2
|
my @new; |
33
|
1
|
|
|
|
|
5
|
for my $tree (@{$self->{trees}}) { |
|
1
|
|
|
|
|
3
|
|
34
|
2
|
|
|
|
|
35
|
push @new, $tree->left; |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
33
|
|
|
22
|
return (ref $self || $self)->new_from_element(\@new, $self); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub next { |
40
|
22
|
|
|
22
|
1
|
35
|
my $self = shift; |
41
|
22
|
|
|
|
|
34
|
my @new; |
42
|
22
|
|
|
|
|
34
|
for my $tree (@{$self->{trees}}) { |
|
22
|
|
|
|
|
46
|
|
43
|
29
|
|
|
|
|
77
|
push @new, grep { $_ } $tree->right; |
|
29
|
|
|
|
|
651
|
|
44
|
|
|
|
|
|
|
} |
45
|
22
|
|
33
|
|
|
84
|
return (ref $self || $self)->new_from_element(\@new, $self); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub tagname { |
49
|
16
|
|
|
16
|
1
|
43
|
my $self = shift; |
50
|
16
|
100
|
|
|
|
40
|
my $method = @_ ? 'setNodeName' : 'nodeName'; |
51
|
|
|
|
|
|
|
|
52
|
16
|
|
|
|
|
22
|
my @retval = map { $_->{node}->$method(@_) } @{$self->{trees}}; |
|
16
|
|
|
|
|
108
|
|
|
16
|
|
|
|
|
32
|
|
53
|
16
|
50
|
|
|
|
121
|
return wantarray ? @retval : $retval[0]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
139
|
|
|
139
|
|
662
|
sub _node_id { $_[1]{node}->unique_key } |
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |