.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "XML::Parser::Lite 3"
.TH XML::Parser::Lite 3 2025-01-22 "perl v5.40.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
XML::Parser::Lite \- Lightweight pure\-perl XML Parser (based on regexps)
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\& use XML::Parser::Lite;
\&
\& $p1 = new XML::Parser::Lite;
\& $p1\->setHandlers(
\& Start => sub { shift; print "start: @_\en" },
\& Char => sub { shift; print "char: @_\en" },
\& End => sub { shift; print "end: @_\en" },
\& );
\& $p1\->parse(\*(AqHello World!\*(Aq);
\&
\& $p2 = new XML::Parser::Lite
\& Handlers => {
\& Start => sub { shift; print "start: @_\en" },
\& Char => sub { shift; print "char: @_\en" },
\& End => sub { shift; print "end: @_\en" },
\& }
\& ;
\& $p2\->parse(\*(AqHello cruel World!\*(Aq);
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
This module implements an XML parser with a interface similar to
XML::Parser. Though not all callbacks are supported, you should be able to
use it in the same way you use XML::Parser. Due to using experimental regexp
features it'll work only on Perl 5.6 and above and may behave differently on
different platforms.
.PP
Note that you cannot use regular expressions or split in callbacks. This is
due to a limitation of perl's regular expression implementation (which is
not re-entrant).
.SH SUBROUTINES/METHODS
.IX Header "SUBROUTINES/METHODS"
.SS new
.IX Subsection "new"
Constructor.
.PP
The \fBnew()\fR method returns the object called on when called as object method.
This behaviour was inherited from SOAP::Lite,
which XML::Parser::Lite was split out from.
This means that the following effectively is
a no-op if \f(CW$obj\fR is a object:
.PP
.Vb 1
\& $obj = $obj\->new();
.Ve
.PP
New accepts a single named parameter, \f(CW\*(C`Handlers\*(C'\fR with a hash ref as value:
.PP
.Vb 7
\& my $parser = XML::Parser::Lite\->new(
\& Handlers => {
\& Start => sub { shift; print "start: @_\en" },
\& Char => sub { shift; print "char: @_\en" },
\& End => sub { shift; print "end: @_\en" },
\& }
\& );
.Ve
.PP
The handlers given will be passed to setHandlers.
.SS setHandlers
.IX Subsection "setHandlers"
Sets (or resets) the parsing handlers. Accepts a hash with the handler names
and handler code references as parameters. Passing \f(CW\*(C`undef\*(C'\fR instead of a
code reference replaces the handler by a no-op.
.PP
The following handlers can be set:
.PP
.Vb 5
\& Init
\& Start
\& Char
\& End
\& Final
.Ve
.PP
All other handlers are ignored.
.PP
Calling setHandlers without parameters resets all handlers to no-ops.
.SS parse
.IX Subsection "parse"
Parses the XML given. In contrast to XML::Parser's parse
method, \fBparse()\fR only parses strings.
.SH "Handler methods"
.IX Header "Handler methods"
.SS Init
.IX Subsection "Init"
Called before parsing starts. You should perform any necessary initializations
in Init.
.SS Start
.IX Subsection "Start"
Called at the start of each XML node. See XML::Parser for details.
.SS Char
.IX Subsection "Char"
Called for each character sequence. May be called multiple times for the
characters contained in an XML node (even for every single character).
Your implementation has to make sure that it captures all characters.
.SS End
.IX Subsection "End"
Called at the end of each XML node. See XML::Parser for details
.SS Comment
.IX Subsection "Comment"
See XML::Parser for details
.SS XMLDecl
.IX Subsection "XMLDecl"
See XML::Parser for details
.SS Doctype
.IX Subsection "Doctype"
See XML::Parser for details
.SS Final
.IX Subsection "Final"
Called at the end of the parsing process. You should perform any necessary
cleanup here.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
XML::Parser \- a full-blown XML Parser, on which XML::Parser::Lite is based.
Requires a C compiler and the \fIexpat\fR XML parser.
.PP
XML::Parser::LiteCopy \- a fork in XML::Parser::Lite::Tree.
.PP
YAX \- another pure-perl module for XML parsing.
.PP
XML::Parser::REX \- another module that parses XML with regular expressions.
.SH COPYRIGHT
.IX Header "COPYRIGHT"
Copyright (C) 2000\-2007 Paul Kulchenko. All rights reserved.
.PP
Copyright (C) 2008 Martin Kutter. All rights reserved.
.PP
Copyright (C) 2013\-2015 Fred Moyer. All rights reserved.
.PP
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
.PP
This parser is based on "shallow parser"
Copyright (c) 1998, Robert D. Cameron.
.SH AUTHORS
.IX Header "AUTHORS"
Paul Kulchenko (paulclinger@yahoo.com)
.PP
Martin Kutter (martin.kutter@fen\-net.de)
.PP
Fred Moyer (fred@redhotpenguin.com)
.PP
Additional handlers supplied by Adam Leggett.
.SH CONTRIBUTORS
.IX Header "CONTRIBUTORS"
David Steinbrunner (dsteinbrunner@pobox.com)
.PP
Neil Bowers (neil@bowers.com)
.PP
Paul Cochrane (paul@liekut.de)