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 X 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
34 selection of which can be obtained by XML::Entities::Data::names(),
35 or "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 The list of entities is defined in the XML::Entities::Data module. The
56 list can be generated from the w3.org definition (or any other). Check
57 "perldoc XML::Entities::Data" for more details.
58
60 HTML::Entities, XML::Entities::Data
61
63 Copyright 2007 Oldrich Kruza Oldrich.Kruza@sixtease.net. All rights
64 reserved.
65
66 This library is free software; you can redistribute it and/or modify it
67 under the same terms as Perl itself.
68
69
70
71perl v5.12.0 2008-11-26 XML::Entities(3)