Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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.

Replies are listed 'Best First'.
Re^2: XML::Twig's twig_print_outside_roots adds extra blank lines to output
by ateague (Monk) 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?
[robby_dobby]: What's the site for YAPC::EU?
[LanX]: Robby Dobby no IIRC Sinai is already part of Asia
[robby_dobby]: blogs.perl.org page for yapceu is out of date by 2 years
[robby_dobby]: LanX: Sharm-el-Sheikh is in Egypt
[choroba]: act.yapc.eu
[robby_dobby]: Thanks, choroba
[LanX]: yes and Egypt (like Turkey and Russia) belongs to two continents
[choroba]: Also Europe and Asia are geographically one continent, the division is political
[robby_dobby]: I always thought everything on the other side of Suez to be Africa. That's an entire continent
[LanX]: Sinai_Peninsula

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2017-04-24 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.