1XML::Parser::LiteCopy(3U)ser Contributed Perl DocumentatiXoMnL::Parser::LiteCopy(3)
2
3
4

NAME

6       XML::Parser::LiteCopy - Lightweight regexp-based XML parser
7

SYNOPSIS

9         use XML::Parser::LiteCopy;
10
11         $p1 = new XML::Parser::LiteCopy;
12         $p1->setHandlers(
13           Start => sub { shift; print "start: @_\n" },
14           Char => sub { shift; print "char: @_\n" },
15           End => sub { shift; print "end: @_\n" },
16         );
17         $p1->parse('<foo id="me">Hello World!</foo>');
18
19         $p2 = new XML::Parser::LiteCopy
20           Handlers => {
21             Start => sub { shift; print "start: @_\n" },
22             Char => sub { shift; print "char: @_\n" },
23             End => sub { shift; print "end: @_\n" },
24           }
25         ;
26         $p2->parse('<foo id="me">Hello <bar>cruel</bar> World!</foo>');
27

DESCRIPTION

29       This Perl implements an XML parser with a interface similar to
30       XML::Parser. Though not all callbacks are supported, you should be able
31       to use it in the same way you use XML::Parser. Due to using
32       experimantal regexp features it'll work only on Perl 5.6 and above and
33       may behave differently on different platforms.
34
35       Note that you cannot use regular expressions or split in callbacks.
36       This is due to a limitation of perl's regular expression implementation
37       (which is not re-entrant).
38

SUBROUTINES/METHODS

40   new
41       Constructor.
42
43       As (almost) all SOAP::Lite constructors, new() returns the object
44       called on when called as object method. This means that the following
45       effectifely is a no-op if $obj is a object:
46
47        $obj = $obj->new();
48
49       New accepts a single named parameter, "Handlers" with a hash ref as
50       value:
51
52        my $parser = XML::Parser::Lite->new(
53           Handlers => {
54               Start => sub { shift; print "start: @_\n" },
55               Char => sub { shift; print "char: @_\n" },
56               End => sub { shift; print "end: @_\n" },
57           }
58        );
59
60       The handlers given will be passed to setHandlers.
61
62   setHandlers
63       Sets (or resets) the parsing handlers. Accepts a hash with the handler
64       names and handler code references as parameters. Passing "undef"
65       instead of a code reference replaces the handler by a no-op.
66
67       The following handlers can be set:
68
69        Init
70        Start
71        Char
72        End
73        Final
74        CData
75        Doctype
76        Comment
77        PI
78
79       All other handlers are ignored.
80
81       Calling setHandlers without parameters resets all handlers to no-ops.
82
83   parse
84       Parses the XML given. In contrast to XML::Parser's parse method,
85       parse() only parses strings.
86

Handler methods

88   Init
89       Called before parsing starts. You should perform any necessary
90       initializations in Init.
91
92   Start
93       Called at the start of each XML node. See XML::Parser for details.
94
95   Char
96       Called for each character sequence. May be called multiple times for
97       the characters contained in an XML node (even for every single
98       character).  Your implementation has to make sure that it captures all
99       characters.
100
101   End
102       Called at the end of each XML node. See XML::Parser for details
103
104   Comment
105       See XML::Parser for details
106
107   PI
108       See XMLDecl in XML::Parser for details, but also includes other
109       processing instructions
110
111   Doctype
112       See XML::Parser for details
113
114   Final
115       Called at the end of the parsing process. You should perform any
116       neccessary cleanup here.
117

SEE ALSO

119        XML::Parser
120
122       Copyright (C) 2000-2007 Paul Kulchenko. All rights reserved.
123
124       Copyright (C) 2008 Martin Kutter. All rights reserved.
125
126       Copyright (C) 2009 Cal Henderson. All rights reserved.
127
128       This library is free software; you can redistribute it and/or modify it
129       under the same terms as Perl itself.
130
131       This parser is based on "shallow parser"
132       http://www.cs.sfu.ca/~cameron/REX.html Copyright (c) 1998, Robert D.
133       Cameron.
134

AUTHOR

136       Paul Kulchenko (paulclinger@yahoo.com)
137
138       Martin Kutter (martin.kutter@fen-net.de)
139
140       Additional handlers supplied by Adam Leggett.
141
142       Further modifications by Cal Henderson.
143
144
145
146perl v5.32.1                      2021-01-27          XML::Parser::LiteCopy(3)
Impressum