1XML::LibXML::NodeList(3U)ser Contributed Perl DocumentatiXoMnL::LibXML::NodeList(3)
2
3
4
6 XML::LibXML::NodeList - a list of XML document nodes
7
9 An XML::LibXML::NodeList object contains an ordered list of nodes, as
10 detailed by the W3C DOM documentation of Node Lists.
11
13 my $results = $dom->findnodes('//somepath');
14 foreach my $context ($results->get_nodelist) {
15 my $newresults = $context->findnodes('./other/element');
16 ...
17 }
18
20 new(@nodes)
21 You will almost never have to create a new NodeList object, as it is
22 all done for you by XPath.
23
24 get_nodelist()
25 Returns a list of nodes, the contents of the node list, as a perl list.
26
27 string_value()
28 Returns the string-value of the first node in the list. See the XPath
29 specification for what "string-value" means.
30
31 to_literal()
32 Returns the concatenation of all the string-values of all the nodes in
33 the list.
34
35 to_literal_delimited($separator)
36 Returns the concatenation of all the string-values of all the nodes in
37 the list, delimited by the specified separator.
38
39 to_literal_list()
40 Returns all the string-values of all the nodes in the list as a perl
41 list.
42
43 get_node($pos)
44 Returns the node at $pos. The node position in XPath is based at 1, not
45 0.
46
47 size()
48 Returns the number of nodes in the NodeList.
49
50 pop()
51 Equivalent to perl's pop function.
52
53 push(@nodes)
54 Equivalent to perl's push function.
55
56 append($nodelist)
57 Given a nodelist, appends the list of nodes in $nodelist to the end of
58 the current list.
59
60 shift()
61 Equivalent to perl's shift function.
62
63 unshift(@nodes)
64 Equivalent to perl's unshift function.
65
66 prepend($nodelist)
67 Given a nodelist, prepends the list of nodes in $nodelist to the front
68 of the current list.
69
70 map($coderef)
71 Equivalent to perl's map function.
72
73 grep($coderef)
74 Equivalent to perl's grep function.
75
76 sort($coderef)
77 Equivalent to perl's sort function.
78
79 Caveat: Perl's magic $a and $b variables are not available in $coderef.
80 Instead the two terms are passed to the coderef as arguments.
81
82 reverse()
83 Equivalent to perl's reverse function.
84
85 foreach($coderef)
86 Inspired by perl's foreach loop. Executes the coderef on each item in
87 the list. Similar to "map", but instead of returning the list of values
88 returned by $coderef, returns the original NodeList.
89
90 reduce($coderef, $init)
91 Equivalent to List::Util's reduce function. $init is optional and
92 provides an initial value for the reduction.
93
94 Caveat: Perl's magic $a and $b variables are not available in $coderef.
95 Instead the two terms are passed to the coderef as arguments.
96
97
98
99perl v5.32.0 2020-07-28 XML::LibXML::NodeList(3)