1 # $Id: Objects.pm,v 1.1 2003/08/18 20:20:51 matt Exp $
3 package XML::Parser::Style::Objects;
9 $expat->{Curlist} = $expat->{Tree} = [];
16 my $class = "${$expat}{Pkg}::$tag";
17 my $newobj = bless { @_, Kids => $newlist }, $class;
18 push @{ $expat->{Lists} }, $expat->{Curlist};
19 push @{ $expat->{Curlist} }, $newobj;
20 $expat->{Curlist} = $newlist;
26 $expat->{Curlist} = pop @{ $expat->{Lists} };
32 my $class = "${$expat}{Pkg}::Characters";
33 my $clist = $expat->{Curlist};
36 if ($pos >= 0 and ref($clist->[$pos]) eq $class) {
37 $clist->[$pos]->{Text} .= $text;
39 push @$clist, bless { Text => $text }, $class;
45 delete $expat->{Curlist};
46 delete $expat->{Lists};
55 XML::Parser::Style::Objects
60 my $p = XML::Parser->new(Style => 'Objects', Pkg => 'MyNode');
61 my $tree = $p->parsefile('foo.xml');
65 This module implements XML::Parser's Objects style parser.
67 This is similar to the Tree style, except that a hash object is created for
68 each element. The corresponding object will be in the class whose name
69 is created by appending "::" and the element name to the package set with
70 the Pkg option. Non-markup text will be in the ::Characters class. The
71 contents of the corresponding object will be in an anonymous array that
72 is the value of the Kids property for that object.
76 L<XML::Parser::Style::Tree>