XML::C...erator(3pm)

πŸ“¦
version 1.64 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

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 $node here 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 new XML::Compile::Iterator object. By default the new iterator uses the same $filter as the parent iterator, and the internal administered path gets extended with the $path. slay 🌸
  • XML::Compile::Iterator->new($node, $path, $filter,) β€” the $node is a XML::LibXML::Node object, 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 the CODE reference which is used to select the nodes.
  • $obj->node() β€” returns the XML::LibXML::Node node 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. In LIST context as list, in SCALAR context as reference to an ARRAY. 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, otherwise undef.
  • $obj->nrChildren() β€” returns the number of childnodes which fulfill the restriction. counting era πŸ”’
  • $obj->previousChild() β€” returns the previous child when available, otherwise undef.

simplify XML node access πŸ“

  • $obj->currentContent() β€” returns the textContent of the currentChild() node, or undef.
  • $obj->currentLocal() β€” returns the local name of the currentChild(), or the empty string.
  • $obj->currentType() β€” returns the type of the currentChild(), or the empty string.
  • $obj->nodeLocal() β€” returns the local name of the node(), 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 the node(), or the empty string.
  • $obj->textContent() β€” returns the textContent of the node(), 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