XML::C...erator(3pm)
NAME π
XML::Compile::Iterator β reduce view on a node tree β¨
okay so bestie, this page is XML::C...erator(3pm), and it lives in the User Contributed Perl Documentation section of your manual, just so you know where you are π«Ά
SYNOPSIS π
ngl the original page has literally nothing in this section. no synopsis. zero. the void. I'm not gonna invent one for you π
DESCRIPTION π¦
Okay so the tea: it would have been <em>so</em> nice to just use XML::LibXML::Iterator, right? But at the moment of this writing, that module is not maintained. Not me being dramatic, that's just the facts π
Besides, this implementation of the iterator is more specific for our purpose. And the main user for this object currently is XML::Compile::Translate. iconic behavior honestly π
METHODS π
Constructors β¨
$obj->descend( [$node, [$path, [$filter]]] )β the$nodehere is a child of the node handled by the iterator where this method is called upon. No explicit$node? Then the current node gets used, easy. What you get back is a brand newXML::Compile::Iteratorobject. By default the new iterator uses the same$filteras the parent iterator, and the internal administered path gets extended with the$path. slay πΈXML::Compile::Iterator->new($node, $path, $filter,)β the$nodeis aXML::LibXML::Nodeobject, and it's the direct children of that node that get inspected. π
The $filter is a CODE reference which is called for each child node. The only parameter is the parent $node, and then it must return either true or false. True means the node is selected, periodt. And listen β the FILTERS is applied to all children of the $node once, when the first child is requested by the program. one time only bestie, no repeats π«
Attributes π
$obj->filter()β returns theCODEreference which is used to select the nodes.$obj->node()β returns theXML::LibXML::Nodenode of which the children are walked through.$obj->path()β the path represents the location where the node is, like a symbolic link, how you got there. it's giving directions to the function π§
Scanning π₯
$obj->childs()β returns the child nodes which fulfil the filter requirements. InLISTcontext as list, inSCALARcontext as reference to anARRAY. versatile queen π$obj->currentChild()β returns the current child node.$obj->firstChild()β returns the first child node. Does not change the current position. respectful, we love that π«Ά$obj->lastChild()β returns the last child node which fulfills the requirements. Does not change the current position either. so chill β¨$obj->nextChild()β returns the next child when available, otherwiseundef.$obj->nrChildren()β returns the number of childnodes which fulfill the restriction. counting era π’$obj->previousChild()β returns the previous child when available, otherwiseundef.
simplify XML node access π
$obj->currentContent()β returns thetextContentof thecurrentChild()node, or undef.$obj->currentLocal()β returns the local name of thecurrentChild(), or the empty string.$obj->currentType()β returns the type of thecurrentChild(), or the empty string.$obj->nodeLocal()β returns the local name of thenode(), or the empty string.$obj->nodeNil()β returns true if the current node has"xsi:type="true"". yes the quotes are doing that, don't come for me, that's literally what the page says π$obj->nodeType()β returns the type of thenode(), or the empty string.$obj->textContent()β returns thetextContentof thenode(), or undef.
SEE ALSO π
This module is part of XML-Compile distribution version 1.64, built on October 21, 2024. Website: http://perl.overmeer.net/xml-compile/ π¦
LICENSE π
Copyrights 2006-2024 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/ π
and that's the whole page bestie!! ππβ¨ππ¦πΈπ π«Ά
this little manual moment was brought to you by perl v5.40.0, dated 2024-10-27, and filed under XML::C...erator(3pm). go forth and iterate, main character ππ
π¦ where this page comes from
- debian trixie: libxml-compile-perl 1.64-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libxml-compile-perl 1.64-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libxml-compile-perl 1.64-1 Β· 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