1XML::Grove::AsString(3)User Contributed Perl DocumentatioXnML::Grove::AsString(3)
2
3
4
6 XML::Grove::AsString - output content of XML objects as a string
7
9 use XML::Grove::AsString;
10
11 # Using as_string method on XML::Grove::Document or XML::Grove::Element:
12 $string = $xml_object->as_string OPTIONS;
13 $string = $element->attr_as_string $attr, OPTIONS;
14
15 # Using an XML::Grove::AsString instance:
16 $writer = new XML::Grove::AsString OPTIONS;
17
18 $string = $writer->as_string($xml_object);
19 $writer->as_string($xml_object, $file_handle);
20
22 Calling `"as_string"' on an XML object returns the character data
23 contents of that object as a string, including all elements below that
24 object. Calling `"attr_as_string"' on an element returns the contents
25 of the named attribute as a string. Comments, processing instructions,
26 and, by default, entities all return an empty string.
27
28 OPTIONS may either be a key-value list or a hash containing the options
29 described below. OPTIONS may be modified directly in the object. The
30 default options are no filtering and entities are mapped to empty
31 strings.
32
34 Filter
35 `"Filter"' is an anonymous sub that gets called to process
36 character data before it is appended to the string to be returned.
37 This can be used, for example, to escape characters that are
38 special in output formats. The `"Filter"' sub is called like this:
39
40 $string = &$filter ($character_data);
41
42 EntityMap
43 `"EntityMap"' is an object that accepts `"lookup"' methods or an
44 anonymous sub that gets called with the entity replacement text
45 (data) and mapper options as arguments and returns the
46 corresponding character replacements. It is called like this if it
47 is an object:
48
49 $replacement_text = $entity_map->lookup ($entity_data,
50 $entity_map_options);
51
52 or this if it is a sub:
53
54 $replacement_text = &$entity_map ($entity_data,
55 $entity_map_options);
56
57 EntityMapOptions
58 `"EntityMapOptions"' is a hash passed through to the `"lookup"'
59 method or anonymous sub, the type of value is defined by the entity
60 mapping package or the anonymous sub.
61
62 EntityMapFilter
63 `"EntityMapFilter"' is a flag to indicate if mapped entities should
64 be filtered after mapping.
65
67 Here is an example of entity mapping using the Text::EntityMap module:
68
69 use Text::EntityMap;
70 use XML::Grove::AsString;
71
72 $html_iso_dia = Text::EntityMap->load ('ISOdia.2html');
73 $html_iso_pub = Text::EntityMap->load ('ISOpub.2html');
74 $html_map = Text::EntityMap->group ($html_iso_dia,
75 $html_iso_pub);
76
77 $element->as_string (EntityMap => $html_map);
78
80 Ken MacLeod, ken@bitsko.slc.ut.us
81
83 perl(1), XML::Grove(3)
84
85 Extensible Markup Language (XML) <http://www.w3c.org/XML>
86
87
88
89perl v5.10.1 1999-08-25 XML::Grove::AsString(3)