Tree::...odeSet(3pm)
π Tree::XPathEngine::NodeSet π
okay bestie, so this page is straight outta the User Contributed Perl Documentation corner of the manual-verse, and it's all about Tree::XPathEngine::NodeSet β a list of XML document nodes. yeah. that's the whole vibe. let's get into it π¦
β¨ NAME β¨
Tree::XPathEngine::NodeSet β literally just a list of XML document nodes. that's it. that's the girl. π
πΈ DESCRIPTION πΈ
so a Tree::XPathEngine::NodeSet object is holding an ordered list of nodes. ordered. like a queue at a boba shop but with XML.
and every single node in there is formatted the exact same way as described over in Tree::XPathEngine::XMLParser. no cap, go read that one if you need the deets on the node format. π
π SYNOPSIS π
here's the whole moment, verbatim, no edits:
my $results = $xp->find('//someelement');
if (!$results->isa('Tree::XPathEngine::NodeSet')) {
print "Found $results\n";
exit;
}
foreach my $context ($results->get_nodelist) {
my $newresults = $xp->find('./other/element', $context);
...
}
π API π
π§ new()
bestie you will almost never have to make a new NodeSet object yourself. XPath does it all for you, behind the scenes, like a personal assistant. let her cook. π₯
π get_nodelist()
hands you a list of nodes. for what a node even looks like, go check Tree::XPathEngine::XMLParser. π«
β xpath_string_value()
gives you the string-value of the first node in the list. and if you're like "what is a string-value" β that's an XPath spec thing, the spec knows, go ask the spec. π
π xpath_to_literal()
concatenates all the string-values of all the nodes in the list and hands you the whole glooped-together result. every node. no skipping. π«Ά
π get_node($pos)
returns the node sitting at $pos. β οΈ heads up bestie, XPath positions are 1-based, not 0-based β so the first node is at 1. do not come in here with your zeroes, the vibes will be off. π
π size()
tells you how many nodes are in the NodeSet. a headcount. a roll call. π
π
pop()
same energy as perl's own pop function. π
β¨ push(@nodes)
same energy as perl's own push function. π
π¦ append($nodeset)
hand it a nodeset and it takes that nodeset's list of nodes and appends them to the end of the current list. back of the line, babes. πΆββοΈ
πΈ shift()
same energy as perl's own shift function. π
π unshift(@nodes)
same energy as perl's own unshift function. π
π prepend($nodeset)
hand it a nodeset and it takes that nodeset's list of nodes and prepends them to the front of the current list. cutting the line, but make it legal. π
β xpath_get_root_node
returns the root node of the first node in the set. going straight to the top, main character behaviour. π§
π₯ sort
returns a sorted nodeset, sorted using the "cmp" method on nodes. cute and orderly. β¨
π remove_duplicates
returns a sorted nodeset containing only unique nodes. β οΈ but listen: the input nodeset MUST be sorted. like, that is not optional. sort it first or perish. π
π xpath_to_boolean
returns true if the nodeset is not empty. empty nodeset? false. got anything in there? true. simple as. β
π xpath_to_number
returns the concatenation of all the string-values of all the nodes in the list, as a Tree::XPathEngine::Number object; π«Ά
ngl the whole point of this class is just: XPath hands you a pile of nodes, and this is the wrapper that lets you count them, sort them, dedupe them, and convert them into strings, literals, booleans and numbers. that's the tea. β
okay that's the page!! and for the little sign-off moment at the bottom, shoutout to the source: this is perl v5.36.0, dated 2022-11-20. iconic. periodt. πβ¨π
π¦ where this page comes from
- debian bookworm: libtree-xpathengine-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtree-xpathengine-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtree-xpathengine-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtree-xpathengine-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtree-xpathengine-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms