in reply to Re^2: Printing element without nested children in XML::Twig
in thread Printing element without nested children in XML::Twig

It seems to me that you are fighting the tool instead of using its strength. I think it would be easier to add the buttons directly in the twig, and then printing the entire twig at once. The loop would look like this (untested):

foreach my $elt ($twig->root->descendants( '#ELT')) { $elt->insert_new_element( 'before', button => { attribute });} $twig->print;

Of course the simple answer to your question is that the xml_text_only (I hate that name!) method would do it. But really, don't use it.