{"id":7414,"date":"2022-12-20T19:38:00","date_gmt":"2022-12-20T22:38:00","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/xmllibxmlnodelist-man3\/"},"modified":"2022-12-20T19:38:00","modified_gmt":"2022-12-20T22:38:00","slug":"xmllibxmlnodelist-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/xmllibxmlnodelist-man3\/","title":{"rendered":"XML::LibXML::NodeList (man3)"},"content":{"rendered":"<h1 align=\"center\">XML::LibXML::NodeList<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#API\">API<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">XML::LibXML::NodeList \u2212 a list of XML document nodes<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">An XML::LibXML::NodeList object contains an ordered list of nodes, as detailed by the W3C <small>DOM<\/small> documentation of Node Lists.<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">my $results = $dom\u2212>findnodes(&#8216;\/\/somepath&#8217;); <br \/> foreach my $context ($results\u2212>get_nodelist) { <br \/> my $newresults = $context\u2212>findnodes(&#8216;.\/other\/element&#8217;); <br \/> &#8230; <br \/> }<\/p>\n<h2>API <a name=\"API\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>new(@nodes)<\/b> <br \/> You will almost never have to create a new NodeList object, as it is all done for you by XPath.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>get_nodelist()<\/b> <br \/> Returns a list of nodes, the contents of the node list, as a perl list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>string_value()<\/b> <br \/> Returns the string-value of the first node in the list. See the XPath specification for what &#8220;string-value&#8221; means.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>to_literal()<\/b> <br \/> Returns the concatenation of all the string-values of all the nodes in the list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>to_literal_delimited($separator)<\/b> <br \/> Returns the concatenation of all the string-values of all the nodes in the list, delimited by the specified separator.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>to_literal_list()<\/b> <br \/> Returns all the string-values of all the nodes in the list as a perl list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>get_node($pos)<\/b> <br \/> Returns the node at $pos. The node position in XPath is based at 1, not 0.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>size()<\/b> <br \/> Returns the number of nodes in the NodeList.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>pop()<\/b> <br \/> Equivalent to perl\u2019s pop function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>push(@nodes)<\/b> <br \/> Equivalent to perl\u2019s push function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>append($nodelist)<\/b> <br \/> Given a nodelist, appends the list of nodes in $nodelist to the end of the current list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>shift()<\/b> <br \/> Equivalent to perl\u2019s shift function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>unshift(@nodes)<\/b> <br \/> Equivalent to perl\u2019s unshift function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>prepend($nodelist)<\/b> <br \/> Given a nodelist, prepends the list of nodes in $nodelist to the front of the current list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>map($coderef)<\/b> <br \/> Equivalent to perl\u2019s map function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>grep($coderef)<\/b> <br \/> Equivalent to perl\u2019s grep function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>sort($coderef)<\/b> <br \/> Equivalent to perl\u2019s sort function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Caveat: Perl\u2019s magic $a and $b variables are not available in $coderef. Instead the two terms are passed to the coderef as arguments.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>reverse()<\/b> <br \/> Equivalent to perl\u2019s reverse function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>foreach($coderef)<\/b> <br \/> Inspired by perl\u2019s foreach loop. Executes the coderef on each item in the list. Similar to &#8220;map&#8221;, but instead of returning the list of values returned by $coderef, returns the original NodeList.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>reduce($coderef, $init)<\/b> <br \/> Equivalent to List::Util\u2019s reduce function. $init is optional and provides an initial value for the reduction.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Caveat: Perl\u2019s magic $a and $b variables are not available in $coderef. Instead the two terms are passed to the coderef as arguments.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  XML::LibXML::NodeList \u2212 a list of XML document nodes <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3726],"class_list":["post-7414","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-xmllibxmlnodelist"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7414"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7414\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}