Re: Keeping numeric entities intact when parsing and serializing?
by Mirod other posts by this author
Oct 9 2009 11:25PM messages near this date
view in the new Beta List Site
Keeping numeric entities intact when parsing and serializing?
|
Re: Keeping numeric entities intact when parsing and serializing?
& XSLT Nicolas Mendoza wrote:
> Is there some way to keep the entities intact when parsing and serlalizing
> numeric entities?
>
> $ perl -wle 'use XML::LibXML; my $xml_parser = XML::LibXML->new(); my $d =
> $xml_parser->parse_string("<xml>Resolved: i Not resolved:
> %amp;</xml>"); print $d->toString(); '
> <?xml version="1.0"?>
> <xml>Resolved: i Not resolved: %amp;</xml>
You can do this with XML::Twig, by using the keep_encoding option. Beware that
in that case the characters are stored just the way they were in the input, so
if you want to do any kind of comparison, you will have to compare to the string
'i'. Also you will have to take care of escaping < and & yourself.
perl -MXML::Twig -e'XML::Twig-> new( keep_encoding => 1)->parse( "<xml>Resolved:
i Not resolved:%amp;</xml> ")->print'
--
mirod
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Nicolas Mendoza
Mirod
Jenda Krynicky
Nicolas Mendoza
Aristotle Pagaltzis
Nicolas Mendoza
Aristotle Pagaltzis
Petr Pajas
Nicolas Mendoza
Petr Pajas
Nicolas Mendoza
Aristotle Pagaltzis
Nicolas Mendoza
Nicolas Mendoza
Petr Pajas
|