in reply to Is it possible to parse an XML file recursively using XML::Twig?

I tried with XML::LibXML::Reader instead. It's just an example (it doesn't handle processing instructions, comments, entities etc.), but it could get you started.
#!/usr/bin/perl use warnings; use strict; use XML::LibXML::Reader; my $reader = 'XML::LibXML::Reader'->new(location => shift) or die; my $node; while ($reader->read) { if ($reader->nodeType == XML_READER_TYPE_ELEMENT) { $node = $reader->copyCurrentNode(0); } elsif ($reader->nodeType == XML_READER_TYPE_TEXT) { $node->appendText($reader->copyCurrentNode(0)); } elsif ($reader->nodeType == XML_READER_TYPE_END_ELEMENT) { print $node, "\n"; } }

copyCurrentNode(0) creates a "shallow" copy, i.e. it doesn't go into the subtree. It keeps the attributes, though.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ