Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: XML Twig sprint output not preserving > entity

by Mr. Muskrat (Canon)
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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989123]
help
Chatterbox?
[GotToBTru]: 99% of all deaths take place within 24 hours of ingesting di-hydrogen monoxide
[GotToBTru]: time for some C8H10N4O2 for me
[ambrus]: GotToBTru: wait, you tell only the atom totals of what you want? Is that like ordering food in a restaurant by telling only the nutrient amounts you need, or
[ambrus]: like when a medieval scientist supposedly proves his priority inventing something by having previously published an anagram of a thousand letters long summary of the invention?

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2016-12-06 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.