1XML::Entities(3) User Contributed Perl Documentation XML::Entities(3)
2
3
4
6 XML::Entities - Decode strings with XML entities
7
9 use XML::Entities;
10
11 $a = "Tom & Jerry © Warner Bros.";
12 $b = XML::Entities::decode('all', $a);
13 $c = XML::Entities::numify('all', $a);
14 # now $b is "Tom & Jerry © Warner Bros.
15 # and $c is "Tom & Jerry © Warner Bros."
16
17 # void context modifies the arguments
18 XML::Entities::numify('all', $a);
19 XML::Entities::decode('all', $a, $c);
20 # Now $a, $b and $c all contain the decoded string
21
23 Based upon the HTML::Entities module by Gisle Aas
24
25 This module deals with decoding of strings with XML character entities.
26 The module provides two functions:
27
28 decode( $entity_set, $string, ... )
29 This routine replaces XML entities from $entity_set found in the
30 $string with the corresponding Unicode character. Unrecognized
31 entities are left alone.
32
33 The $entity_set can either be a name of an entity set - the selec‐
34 tion of which can be obtained by XML::Entities::Data::names(), or
35 "all" for a union, or alternatively a hashref which maps entity
36 names (without leading &'s) to the corresponding Unicode characters
37 (or strings).
38
39 If multiple strings are provided as argument they are each decoded
40 separately and the same number of strings are returned.
41
42 If called in void context the arguments are decoded in-place.
43
44 Note: If your version of "HTML::Parser" was built without Unicode
45 support, then "XML::Entities" uses a regular expression to do the
46 decoding, which is slower.
47
48 numify( $entity_set, $string, ... )
49 This functions converts named XML entities to numeric XML entities.
50 It is less robust than the "decode" function in the sense that it
51 doesn't capture improperly terminated entities. It behaves like
52 "decode" in treating parameters and returning values.
53
54 XML::Entities::Data
55
56 The list of entities is defined in the XML::Entities::Data module. The
57 list can be generated from the w3.org definition (or any other). Check
58 "perldoc XML::Entities::Data" for more details.
59
61 HTML::Entities, XML::Entities::Data
62
64 Copyright 2007 Oldrich Kruza Oldrich.Kruza@sixtease.net. All rights
65 reserved.
66
67 This library is free software; you can redistribute it and/or modify it
68 under the same terms as Perl itself.
69
70
71
72perl v5.8.8 2008-03-27 XML::Entities(3)