.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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::SAX::Expat::Incremental 3pm" .TH XML::SAX::Expat::Incremental 3pm "2022-06-26" "perl v5.34.0" "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::SAX::Expat::Incremental \- XML::SAX::Expat subclass for non\-blocking (incremental) parsing, with XML::Parser::ExpatNB. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XML::SAX::Expat::Incremental; \& \& # don\*(Aqt do this, use XML::SAX::ParserFactory \& my $p = XML::SAX::Expat::Incremental\->new( Handler => MyHandler\->new ); \& \& $p\->parse_start; \& \& while (){ \& $p\->parse_more($_); # or $p\->parse_string($_); \& } \& \& $p\->parse_done; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Most \s-1XML\s0 parsers give a callback interface within an encapsulated loop. That is, you call .PP .Vb 1 \& $p\->parse_whatever($whatever); .Ve .PP And eventually, when \f(CW$whatever\fR is depleted by the parser, \f(CW\*(C`$p\->parse\*(C'\fR will return. .PP Sometimes you don't want the parser to control the loop for you. For example, if you need to retrieve your \s-1XML\s0 in chunks in a funny way, you might need to do something like .PP .Vb 4 \& my $doc = \*(Aq\*(Aq; \& while (defined(my $buffer = get_more_xml())) { \& $doc .= $buffer; \& } \& \& $p\->parse_string($doc); .Ve .PP which is not very convenient, or efficient. You could use perltie to tie a filehandle which does this for you, but that only works some of the time (for example, say you have two inputs coming in simultaneously). .PP XML::Parser::ExpatNB solves this by providing three methods: .IP "parse_start" 4 .IX Item "parse_start" .PD 0 .IP "parse_more" 4 .IX Item "parse_more" .IP "parse_done" 4 .IX Item "parse_done" .PD .PP This interface lets you move the loop to outside the parser, retaining control. .PP The callbacks are executed in the same manner, just that now, when there is no left to parse, instead of taking more data from a source on it's own, the parser returns control to you. .PP .Vb 2 \& $p\->parse_start; # you can omit this \- parse_start will \& # be called automatically as needed \& \& while(defined(my $buffer = get_more_xml())) { \& $p\->parse_more($buffer); \& } \& \& $p\->parse_done; .Ve .PP This module is a subclass of XML::SAX::Expat which is to XML::Parser::ExpatXS as XML::SAX::Expat is to XML::Parser itself. .SH "METHODS" .IX Header "METHODS" .IP "parse_string \s-1STRING\s0" 4 .IX Item "parse_string STRING" .PD 0 .IP "parse_more \s-1STRING\s0" 4 .IX Item "parse_more STRING" .PD These have the same effect, except that parse_more actually calls parse_string with \f(CW@_\fR. You might want to use parse_string because in theory it's more efficient. .Sp This simply continues parsing with the new string, and sends \s-1SAX\s0 events for the data that is complete in the string. .IP "parse_start" 4 .IX Item "parse_start" This calls parse_start on the underlying XML::Parser::ExpatNB object. It's called implicitly when you first call parse_string, though, so you don't have to worry about it. .IP "parse_done" 4 .IX Item "parse_done" This calls parse_done on the underlying XML::Parser::ExpatNB object. You use it to tell the parser you have no more data to give it. .IP "parse" 4 .IX Item "parse" This is used internally as a sort of parse-anything method. Don't use it, instead use \f(CW\*(C`parse_string\*(C'\fR, which invokes this method correctly, and takes simpler options. .SH "SEE ALSO" .IX Header "SEE ALSO" XML::Parser, \s-1XML::SAX\s0, XML::SAX::Expat, XML::SAX::ExpatNB .SH "VERSION CONTROL" .IX Header "VERSION CONTROL" This module is maintained using Darcs. You can get the latest version from , and use \f(CW\*(C`darcs send\*(C'\fR to commit changes. .SH "AUTHOR" .IX Header "AUTHOR" Yuval Kogman .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" .Vb 3 \& Copyright (c) 2005 Yuval Kogman. All rights reserved \& This program is free software; you can redistribute \& it and/or modify it under the same terms as Perl itself. .Ve