# perldoc > XML::LibXML::NodeList

---
type: CommandReference
command: XML::LibXML::NodeList
mode: perldoc
section: 
source: perldoc
---

## Quick Reference

- `$results->get_nodelist()` — return list of nodes as Perl list
- `$results->string_value()` — string-value of first node
- `$results->get_node($pos)` — node at position (1‑based)
- `$results->size()` — number of nodes
- `$results->pop()` — remove and return last node
- `$results->push(@nodes)` — append nodes
- `$results->map($coderef)` — transform list (coderef receives arguments, not `$a`/`$b`)
- `$results->grep($coderef)` — filter list

## Name

**XML::LibXML::NodeList** — a list of XML document nodes

## Synopsis

perl
my $results = $dom->findnodes('//somepath');
foreach my $context ($results->get_nodelist) {
    my $newresults = $context->findnodes('./other/element');
    ...
}
## Description

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

## API

- `new(@nodes)` — create a new NodeList (usually not needed; handled by XPath)
- `get_nodelist()` — returns a list of nodes as a Perl list
- `string_value()` — string-value of the first node (XPath specification)
- `to_literal()` — concatenation of all string-values of all nodes
- `to_literal_delimited($separator)` — concatenation delimited by separator
- `to_literal_list()` — returns all string-values as a Perl list
- `get_node($pos)` — node at position $pos (1‑based)
- `size()` — number of nodes in the list
- `pop()` — equivalent to Perl's `pop`
- `push(@nodes)` — equivalent to Perl's `push`
- `append($nodelist)` — append nodes from another nodelist
- `shift()` — equivalent to Perl's `shift`
- `unshift(@nodes)` — equivalent to Perl's `unshift`
- `prepend($nodelist)` — prepend nodes from another nodelist
- `map($coderef)` — equivalent to Perl's `map`; coderef receives two terms as arguments (not `$a`/`$b`)
- `grep($coderef)` — equivalent to Perl's `grep`; coderef receives terms as arguments
- `sort($coderef)` — equivalent to Perl's `sort`; coderef receives two terms as arguments (not `$a`/`$b`)
- `reverse()` — equivalent to Perl's `reverse`
- `foreach($coderef)` — executes coderef on each item, returns original NodeList (not the mapped values)
- `reduce($coderef, $init)` — equivalent to List::Util's `reduce`; coderef receives two terms as arguments (not `$a`/`$b`); `$init` optional

## See Also

- [XML::LibXML](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ALibXML/markdown)
- [List::Util](https://www.chedong.com/phpMan.php/perldoc/List%3A%3AUtil/markdown)