eff_i_g has asked for the wisdom of the Perl Monks concerning the following question:
Yields...use warnings; use strict; use XML::Twig; my $twig = XML::Twig->new( char_handler => sub { my ($txt) = @_; $txt =~ s/"(.*?)"/'$1'/g; return $txt; }, ### Note: These are included for terminal ease. ### The problem still exists without them. pretty_print => 'indented', keep_encoding => 1, ); $twig->parsestring(*DATA); $twig->flush(); __DATA__ <root> <data>"A", "B—C", "D"</data> </root>
And I was expecting...<root> <data>'A', "B—C', 'D"</data> </root>
Is it possible to parse the content and the entities together in XML::Twig, or must I result to looking for partial matches and saving open and close states?<root> <data>'A', 'B—C', 'D'</data> </root>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Jointly parsing characters and entities in XML::Twig
by mirod (Canon) on Sep 12, 2008 at 16:31 UTC | |
by eff_i_g (Curate) on Sep 12, 2008 at 16:56 UTC | |
by mirod (Canon) on Sep 12, 2008 at 17:15 UTC |