138 lines
2.7 KiB
HTML
138 lines
2.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Parser::Style::Stream</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Parser::Style::Stream</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-10-03<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
XML::Parser::Style::Stream - Stream style for XML::Parser
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use XML::Parser;
|
|
my $p = XML::Parser->new(Style => 'Stream', Pkg => 'MySubs');
|
|
$p->parsefile('foo.xml');
|
|
|
|
{
|
|
package MySubs;
|
|
|
|
sub StartTag {
|
|
my ($e, $name) = @_;
|
|
# do something with start tags
|
|
}
|
|
|
|
sub EndTag {
|
|
my ($e, $name) = @_;
|
|
# do something with end tags
|
|
}
|
|
|
|
sub Characters {
|
|
my ($e, $data) = @_;
|
|
# do something with text nodes
|
|
}
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This style uses the Pkg option to find subs in a given package to call for each event.
|
|
If none of the subs that this
|
|
style looks for is there, then the effect of parsing with this style is
|
|
to print a canonical copy of the document without comments or declarations.
|
|
All the subs receive as their 1st parameter the Expat instance for the
|
|
document they're parsing.
|
|
<P>
|
|
|
|
It looks for the following routines:
|
|
<DL COMPACT>
|
|
<DT id="1">•<DD>
|
|
StartDocument
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Called at the start of the parse .
|
|
<DT id="2">•<DD>
|
|
StartTag
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Called for every start tag with a second parameter of the element type. The <TT>$_</TT>
|
|
variable will contain a copy of the tag and the <TT>%_</TT> variable will contain
|
|
attribute values supplied for that element.
|
|
<DT id="3">•<DD>
|
|
EndTag
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Called for every end tag with a second parameter of the element type. The <TT>$_</TT>
|
|
variable will contain a copy of the end tag.
|
|
<DT id="4">•<DD>
|
|
Text
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Called just before start or end tags with accumulated non-markup text in
|
|
the <TT>$_</TT> variable.
|
|
<DT id="5">•<DD>
|
|
<FONT SIZE="-1">PI</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Called for processing instructions. The <TT>$_</TT> variable will contain a copy of
|
|
the <FONT SIZE="-1">PI</FONT> and the target and data are sent as 2nd and 3rd parameters
|
|
respectively.
|
|
<DT id="6">•<DD>
|
|
EndDocument
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Called at conclusion of the parse.
|
|
<P>
|
|
</DL>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="7"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="8"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="9"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:01 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|