line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::XPath::Diver; |
2
|
2
|
|
|
2
|
|
21620
|
use 5.008005; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
76
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
4
|
2
|
|
|
2
|
|
23
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
5
|
2
|
|
|
2
|
|
1852
|
use parent 'XML::XPath'; |
|
2
|
|
|
|
|
5257
|
|
|
2
|
|
|
|
|
12
|
|
6
|
|
|
|
|
|
|
use XML::XPath::XMLParser; |
7
|
|
|
|
|
|
|
use Class::Builtin (); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub dive { |
12
|
|
|
|
|
|
|
my ($self, $xpath) = @_; |
13
|
|
|
|
|
|
|
my $nodeset = $self->find($xpath); |
14
|
|
|
|
|
|
|
my @nodes = map {__PACKAGE__->new(xml => XML::XPath::XMLParser::as_string($_))} $nodeset->get_nodelist; |
15
|
|
|
|
|
|
|
wantarray ? @nodes : Class::Builtin->can('OO')->([@nodes]); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub attr { |
19
|
|
|
|
|
|
|
my ($self, $attr_name) = @_; |
20
|
|
|
|
|
|
|
my $nodeset = $self->find(sprintf('//@%s', $attr_name)); |
21
|
|
|
|
|
|
|
my $node = $nodeset->shift; |
22
|
|
|
|
|
|
|
$node->getNodeValue; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub text { shift->getNodeText(shift || '/')->value } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub to_string { |
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
my $nodeset = $self->find('/'); |
30
|
|
|
|
|
|
|
XML::XPath::XMLParser::as_string($nodeset->shift); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
__END__ |