1Parser::Style::Stream(3U)ser Contributed Perl DocumentatiPoanrser::Style::Stream(3)
2
3
4
6 XML::Parser::Style::Stream - Stream style for XML::Parser
7
9 use XML::Parser;
10 my $p = XML::Parser->new(Style => 'Stream', Pkg => 'MySubs');
11 $p->parsefile('foo.xml');
12
13 {
14 package MySubs;
15
16 sub StartTag {
17 my ($e, $name) = @_;
18 # do something with start tags
19 }
20
21 sub EndTag {
22 my ($e, $name) = @_;
23 # do something with end tags
24 }
25
26 sub Characters {
27 my ($e, $data) = @_;
28 # do something with text nodes
29 }
30 }
31
33 This style uses the Pkg option to find subs in a given package to call
34 for each event. If none of the subs that this style looks for is
35 there, then the effect of parsing with this style is to print a canoniā
36 cal copy of the document without comments or declarations. All the
37 subs receive as their 1st parameter the Expat instance for the document
38 they're parsing.
39
40 It looks for the following routines:
41
42 * StartDocument
43 Called at the start of the parse .
44
45 * StartTag
46 Called for every start tag with a second parameter of the element
47 type. The $_ variable will contain a copy of the tag and the %_
48 variable will contain attribute values supplied for that element.
49
50 * EndTag
51 Called for every end tag with a second parameter of the element
52 type. The $_ variable will contain a copy of the end tag.
53
54 * Text
55 Called just before start or end tags with accumulated non-markup
56 text in the $_ variable.
57
58 * PI
59 Called for processing instructions. The $_ variable will contain a
60 copy of the PI and the target and data are sent as 2nd and 3rd
61 parameters respectively.
62
63 * EndDocument
64 Called at conclusion of the parse.
65
66
67
68perl v5.8.8 2003-08-18 Parser::Style::Stream(3)