Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: XML Twig sprint output not preserving > entity

by Mr. Muskrat (Abbot)
on Aug 22, 2012 at 19:41 UTC ( #989123=note: print w/ replies, xml ) Need Help??


in reply to XML Twig sprint output not preserving > entity

You need to set keep_encoding.

#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; use Data::Dump qw' dd '; Main( @ARGV ); exit (0); sub Main { my %files; my $filename; my $subprint = sub { my( $twig, $_ ) = @_; push @{ $files{ $filename }}, $_->sprint; return; }; my $twig = XML::Twig->new( ignore_elts => { brief => 'discard', detailed => 'discard' }, keep_encoding => 1, pretty_print => 'indented', TwigHandlers => { 'myroot/classes' => $subprint, }, ); for my $file( @_ ) { $filename = $file; eval { $twig->parsefile( $file ); 1; } or warn "ERROR parsefile($file): $@ "; $twig->purge; } dd \%files; }


Comment on Re: XML Twig sprint output not preserving > entity
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2015-07-01 19:23 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 (17 votes), past polls