XML::XP...:NodeSet(3)
β¨ NAME β¨
okay so bestie, welcome to XML::XPath::NodeSet β it's a list of XML document nodes π and yeah, it lives in the User Contributed Perl Documentation manual section, section 3, iykyk π
πΈ DESCRIPTION πΈ
An XML::XPath::NodeSet object is literally just an ordered list of nodes, no cap π
. It's giving "glow-up for an array," fr fr.
And the nodes inside it? Every single one takes the same format as described over in XML::XPath::XMLParser β so if you need the deets on what a node actually looks like, that's your girl π¦.
π«Ά SYNOPSIS π«Ά
here's the vibe, copy it, run it, slay:
my $results = $xp->find('//someelement');
if (!$results->isa('XML::XPath::NodeSet')) {
print "Found $results\n";
exit;
}
foreach my $context ($results->get_nodelist) {
my $newresults = $xp->find('./other/element', $context);
...
}
π API π
the main character section, periodt.
π new()
bestie you will almost never have to create a new NodeSet object yourself, because XPath handles all of that for you. it's giving "we got you" π not me doing zero work and still getting the results π«Ά
β get_nodelist()
Returns a list of nodes. wanna know the format of those nodes? check XML::XPath::XMLParser, it's all laid out there πΈ
π string_value()
Returns the string-value of the first node in the list. and yes, if you're like "what even is a string-value" β go read the XPath specification, it's the whole vibe check on that term πβ¨
π to_literal()
Returns the concatenation of all the string-values of all the nodes in the list. every single one. gluing them together like friendship bracelets π«Ά
π¦ get_node($pos)
Returns the node at $pos. and here's the tea that trips people up: the node position in XPath is based at 1, not 0 π so don't come at it with your zero-indexed brain, bestie, it will humble you.
π size()
Returns the number of nodes in the NodeSet. that's it, that's the whole thing, iconic behavior π
π pop()
Equivalent to perl's pop function. yes queen, same energy, just wearing a cuter outfit β¨
π§ push(@nodes)
Equivalent to perl's push function. nodes go in at the end, no drama πΈ
π append($nodeset)
Given a nodeset, appends the list of nodes in $nodeset to the end of the current list. like adding more people to the group chat, and they're all welcome π
π₯ shift()
Equivalent to perl's shift function. takes from the front, lowkey always has β¨
π unshift(@nodes)
Equivalent to perl's unshift function. front of the line energy, but make it perl π
π prepend($nodeset)
Given a nodeset, prepends the list of nodes in $nodeset to the front of the current list. main character entrance, literally π
and that's the whole page, bestie!! this gem is documented by perl v5.42.1, dated 2026-04-21 β shoutout to whoever wrote it, you ate π mwah, go process some nodes, ily π«Άβ¨π
π¦ where this page comes from
- fedora 44: perl-XML-XPath 1.49-1.fc44 Β· Artistic-2.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms