XML::XP...:NodeSet(3)

🌟 NAME 🌟

XML::XPathEngine::NodeSet β€” a list of XML document nodes πŸ’… (and yes, this is a User Contributed Perl Documentation page, iykyk 🫢)

🌸 DESCRIPTION 🌸

okay so bestie, an XML::XPathEngine::NodeSet object contains an ordered list of nodes. The nodes each take the same format as described in XML::XPathEngine::XMLParser β€” that's the format tea, no cap ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

here's the vibe, bestie:

        my $results = $xp->find('//someelement');
        if (!$results->isa('XML::XPathEngine::NodeSet')) {
                print "Found $results\n";
                exit;
        }
        foreach my $context ($results->get_nodelist) {
                my $newresults = $xp->find('./other/element', $context);
                ...
        }

πŸ‘‘ API πŸ‘‘

✨ new() ✨

You will almost never have to create a new NodeSet object, because it is all done for you by XPath. Like, XPath handles that for you, periodt πŸ’–

πŸ¦‹ get_nodelist() πŸ¦‹

Returns a list of nodes. See XML::XPathEngine::XMLParser for the format of the nodes. That's the whole tea 🫢

πŸŽ€ string_value() πŸŽ€

Returns the string-value of the first node in the list. See the XPath specification for what "string-value" means β€” yes, that's the actual term, iykyk πŸ’…

🌸 string_values() 🌸

Returns a list of the string-values of all the nodes in the list. all of them, bestie ✨

πŸ”₯ to_literal() πŸ”₯

Returns the concatenation of all the string-values of all the nodes in the list. literally gluing all the string-values together πŸ”₯

⭐ get_node($pos) ⭐

Returns the node at $pos. Important: the node position in XPath is based at 1, not 0 β€” not me forgetting zero-indexing, okay? 😭

πŸ’œ size() πŸ’œ

Returns the number of nodes in the NodeSet. simple, iconic, does what it says πŸ’œ

πŸ“ pop() πŸ“

Equivalent to perl's pop function. yep, that one πŸ“

🌈 push(@nodes) 🌈

Equivalent to perl's push function. same energy, different method 🌈

🧚 append($nodeset) 🧚

Given a nodeset, appends the list of nodes in $nodeset to the end of the current list. adding to the back of the line, slay 🧚

πŸ‘‘ shift() πŸ‘‘

Equivalent to perl's shift function. periodt πŸ‘‘

πŸ’– unshift(@nodes) πŸ’–

Equivalent to perl's unshift function. front-of-the-line behavior, fr fr πŸ’–

🫢 prepend($nodeset) 🫢

Given a nodeset, prepends the list of nodes in $nodeset to the front of the current list. main character energy at the start of the list 🫢

xoxo, your girl πŸ’– β€” source/version perl v5.42.0, date 2013-06-04, page XML::XP...:NodeSet(3). periodt ✨

πŸ“¦ where this page comes from