Codex

XML::LibXML::NodeList

Section: User Contributed Perl Documentation (3pm)

Updated: 2014-04-12

Index?action=index Return to Main Contents


NAME

XML::LibXML::NodeList - a list of XML document nodes

DESCRIPTION

An XML::LibXML::NodeList object contains an ordered list of nodes, as detailed by the W3C DOM documentation of Node Lists.

SYNOPSIS

API

new(@nodes)

You will almost never have to create a new NodeList object, as it is all done for you by XPath.

<H3 CLASS="c1|get_nodelist()

Returns a list of nodes, the contents of the node list, as a perl list.

<H3 CLASS="c1|string_value()

Returns the string-value of the first node in the list. See the XPath specification for what ``string-value'' means.

<H3 CLASS="c1|to_literal()

Returns the concatenation of all the string-values of all the nodes in the list.

to_literal_delimited($separator)

Returns the concatenation of all the string-values of all the nodes in the list, delimited by the specified separator.

<H3 CLASS="c1|to_literal_list()

Returns all the string-values of all the nodes in the list as a perl list.

get_node($pos)

Returns the node at . The node position in XPath is based at 1, not 0.

<H3 CLASS="c1|size()

Returns the number of nodes in the NodeList.

<H3 CLASS="c1|pop()

Equivalent to perl's pop function.

push(@nodes)

Equivalent to perl's push function.

append($nodelist)

Given a nodelist, appends the list of nodes in to the end of the current list.

<H3 CLASS="c1|shift()

Equivalent to perl's shift function.

unshift(@nodes)

Equivalent to perl's unshift function.

prepend($nodelist)

Given a nodelist, prepends the list of nodes in to the front of the current list.

map($coderef)

Equivalent to perl's map function.

grep($coderef)

Equivalent to perl's grep function.

sort($coderef)

Equivalent to perl's sort function.

Caveat: Perl's magic and variables are not available in . Instead the two terms are passed to the coderef as arguments.

<H3 CLASS="c1|reverse()

Equivalent to perl's reverse function.

foreach($coderef)

Inspired by perl's foreach loop. Executes the coderef on each item in the list. Similar to , but instead of returning the list of values returned by , returns the original NodeList.

reduce($coderef, $init)

Equivalent to List::Util's reduce function. is optional and provides an initial value for the reduction.
Caveat: Perl's magic and variables are not available in . Instead the two terms are passed to the coderef as arguments.

Index

NAME

DESCRIPTION

SYNOPSIS

API

new(@nodes)

:<A CLASS="c2" HREF="#lbAG|get_nodelist()]]

:<A CLASS="c2" HREF="#lbAH|string_value()]]

:<A CLASS="c2" HREF="#lbAI|to_literal()]]

to_literal_delimited($separator)

:<A CLASS="c2" HREF="#lbAK|to_literal_list()]]

get_node($pos)

:<A CLASS="c2" HREF="#lbAM|size()]]

:<A CLASS="c2" HREF="#lbAN|pop()]]

push(@nodes)

append($nodelist)

:<A CLASS="c2" HREF="#lbAQ|shift()]]

unshift(@nodes)

prepend($nodelist)

map($coderef)

grep($coderef)

sort($coderef)

:<A CLASS="c2" HREF="#lbAW|reverse()]]

foreach($coderef)

reduce($coderef, $init)