![]() |
![]()
| ![]() |
![]()
NAMEXML::Entities - Decode strings with XML entities SYNOPSISuse XML::Entities; $a = "Tom & Jerry © Warner Bros."; $b = XML::Entities::decode('all', $a); $c = XML::Entities::numify('all', $a); # now $b is "Tom & Jerry © Warner Bros. # and $c is "Tom & Jerry © Warner Bros." # void context modifies the arguments XML::Entities::numify('all', $a); XML::Entities::decode('all', $a, $c); # Now $a, $b and $c all contain the decoded string DESCRIPTIONBased upon the HTML::Entities module by Gisle Aas This module deals with decoding of strings with XML character entities. The module provides two functions:
XML::Entities::DataThe list of entities is defined in the XML::Entities::Data module. The list can be generated from the w3.org definition (or any other). Check "perldoc XML::Entities::Data" for more details. Encoding entitiesThe HTML::Entities module provides a function for encoding entities. You just have to assign the right mapping to the %HTML::Entities::char2entity hash. So, to encode everything that XML::Entities knows about, you'd say: use XML::Entities; use HTML::Entities; %HTML::Entities::char2entity = %{ XML::Entities::Data::char2entity('all'); }; my $encoded = encode_entities('tom&jerry'); # now $encoded is 'tom&jerry' SEE ALSOHTML::Entities, XML::Entities::Data COPYRIGHTCopyright 2012 Jan Oldrich Kruza <sixtease@cpan.org>. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|