Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: XML::Twig's twig_print_outside_roots adds extra blank lines to output

by remiah (Hermit)
on Jun 27, 2014 at 14:17 UTC ( #1091476=note: print w/ replies, xml ) Need Help??


in reply to [SOLVED] XML::Twig's twig_print_outside_roots adds extra blank lines to output

hello ateague.
Sometimes I met the case when pretty print doesn't work with XML::Twig. If pretty print is the problem, how about this?

XML::Twig->new( twig_handlers => { 'statement' => sub { my($twig,$elt)=@_; if( $elt->find_nodes('primary/acct', 0)->trimmed_text() eq + '903264' ){ $twig->flush; }else { $twig->purge; } }, 'statement//*' =>sub {}, #skip descendants of statement '_default_' => sub { #just flush my($twig,$elt)=@_; $twig->flush; } }, #twig_print_outside_roots =>1, pretty_print => 'indented', )->parse(*DATA); __DATA__ same data
This prints pretty with my XML::Twig
C:\temp>perl -MXML::Twig -e "print $XML::Twig::VERSION" 3.42
This example be "potato", becuase it kills the advantage to use twig_root.
good luck.


Comment on Re: XML::Twig's twig_print_outside_roots adds extra blank lines to output
Select or Download Code
Replies are listed 'Best First'.
Re^2: XML::Twig's twig_print_outside_roots adds extra blank lines to output
by ateague (Beadle) on Jun 30, 2014 at 00:22 UTC

    Thank you very much Remiah! That was exactly what I was looking for.

    For those that come after, here is the final code I used to get my desired output:

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1091476]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2015-07-30 19:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls