• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

ex/H27-Aug-2009-4027

inc/Module/H27-Aug-2009-2,6101,933

lib/XML/Parser/Style/H27-Aug-2009-488179

t/H27-Aug-2009-823586

ChangesH A D27-Aug-2009652 3322

LICENSEH A D27-Aug-2009175 74

MANIFESTH A D27-Aug-2009724 3837

META.ymlH A D27-Aug-2009772 3635

Makefile.PLH A D27-Aug-2009591 2720

READMEH A D27-Aug-20094.6 KiB178131

cpants.plH A D27-Aug-2009980 3831

makeall.shH A D27-Aug-2009668 2622

README

1NAME
2    XML::Parser::Style::ETree - Parse xml to simple tree
3
4VERSION
5    Version 0.09
6
7SYNOPSIS
8        use XML::Parser;
9        my $p = XML::Parser->new( Style => 'ETree' );
10
11EXAMPLE
12        <root at="key">
13            <nest>
14                first
15                <v>a</v>
16                mid
17                <v at="a">b</v>
18                <vv></vv>
19                last
20            </nest>
21        </root>
22
23    will be
24
25        {
26            root => {
27                '-at' => 'key',
28                nest => {
29                    '#text' => 'firstmidlast',
30                    vv => '',
31                    v => [
32                        'a',
33                        {
34                            '-at' => 'a',
35                            '#text' => 'b'
36                        }
37                    ]
38                }
39            }
40        }
41
42SPECIAL VARIABLES
43    $TEXT{ATTR} [ = '-' ]
44        Allow to set prefix for name of attribute nodes;
45
46            <item attr="value" />
47            # will be
48            item => { -attr => 'value' };
49
50            # with
51            $TEXT{ATTR} = '+';
52            # will be
53            item => { '+attr' => 'value' };
54
55    $TEXT{NODE} [ = '#text' ]
56        Allow to set name for text nodes
57
58            <item><sub attr="t"></sub>Text value</item>
59            # will be
60            item => { sub => { -attr => "t" }, #text => 'Text value' };
61
62            # with
63            $TEXT{NODE} = '';
64            # will be
65            item => { sub => { -attr => "t" }, '' => 'Text value' };
66
67    $TEXT{JOIN} [ = '' ]
68        Allow to set join separator for text node, splitted by subnodes
69
70            <item>Test1<sub />Test2</item>
71            # will be
72            item => { sub => '', #text => 'Test1Test2' };
73
74            # with
75            $TEXT{JOIN} = '+';
76            # will be
77            item => { sub => '', #text => 'Test1+Test2' };
78
79    $TEXT{TRIM} [ = 1 ]
80        Trim leading and trailing whitespace from text nodes
81
82            <item>  Test1  <sub />  Test2  </item>
83            # will be
84            item => { sub => '', #text => 'Test1Test2' };
85
86            # with
87            $TEXT{TRIM} = 0;
88            # will be
89            item => { sub => '', #text => '  Test1    Test2  ' };
90
91    %FORCE_ARRAY
92        Allow to force nodes to be represented always as arrays. If name is
93        empty string, then ot means ALL
94
95            <item><sub attr="t"></sub>Text value</item>
96
97            # will be
98            item => { sub => { -attr => "t" }, #text => 'Text value' };
99
100            # with
101            $FORCE_ARRAY{sub} = 1;
102            # will be
103            item => { sub => [ { -attr => "t" } ], #text => 'Text value' };
104
105            # with
106            $FORCE_ARRAY{''} = 1;
107            # will be
108            item => [ { sub => [ { -attr => "t" } ], #text => 'Text value' } ];
109
110    %FORCE_HASH
111        Allow to force text-only nodes to be represented always as hashes.
112        If name is empty string, then ot means ALL
113
114            <item><sub>Text value</sub><any>Text value</any></item>
115
116            # will be
117            item => { sub => 'Text value', any => 'Text value' };
118
119            # with
120            $FORCE_HASH{sub} = 1;
121            # will be
122            item => { sub => { #text => 'Text value' }, any => 'Text value' };
123
124            # with
125            $FORCE_HASH{''} = 1;
126            # will be
127            item => { sub => { #text => 'Text value' }, any => { #text => 'Text value' } };
128
129    @STRIP_KEY
130        Allow to strip something from tag names by regular expressions
131
132            <a:item><b:sub>Text value</b:sub></a:item>
133
134            # will be
135            'a:item' => { 'b:sub' => 'Text value' };
136
137            # with
138            @STRIP_KEY = (qr/^[^:]+:/);
139            # will be
140            'item' => { 'sub' => 'Text value' };
141
142SEE ALSO
143    *   XML::Parser
144
145        The parser itself
146
147    *   XML::Parser::EasyTree
148
149        Another EasyTree (I didn't found it before my first commit of this
150        package because of missing '::Style' in it's name)
151
152        But since XML::Parser::EasyTree and XML::Parser::Style::EasyTree use
153        same style name, they're mutual exclusive ;(
154
155        So, all the functionality was moved to ETree, and EasyTree was kept
156        as a compatibility wrapper
157
158    *   XML::Bare
159
160        Very-very fast XML parser. Recommend to look
161
162    *   XML::Hash::LX
163
164        Similar behaviour, same output, but using XML::LibXML
165
166AUTHOR
167    Mons Anderson, <mons at cpan.org>
168
169BUGS
170    None known
171
172COPYRIGHT & LICENSE
173    Copyright 2009 Mons Anderson
174
175    This program is free software; you can redistribute it and/or modify it
176    under the same terms as Perl itself.
177
178