Following example of xml file that contains less than and greater than symbols as entities. When output through sprint, the
> entity is converted to actual symbol. The
< is left alone as desired. Is this bug or option I need to set to keep the
> as indicated after BAR.
#!/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' },
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;
}
XML file:
<?xml version='1.0' standalone='yes'?>
<myroot>
<classes name="SomeClass::AccessLogic">
<public_typedefs>
<members name="Ptr" kind="typedef" type="boost::shared_ptr<
+ BAR >" virtualness="non_virtual">
<brief></brief>
<detailed></detailed>
</members>
</public_typedefs>
</classes>
</myroot>