comparison Lib/IMPL/DOM/XMLReader.pm @ 12:955b2324c1bf

Работа над навигаторами и схемой DOM модели
author Sergey
date Mon, 31 Aug 2009 01:37:43 +0400
parents 63f6653b094e
children bb8d67f811ea
comparison
equal deleted inserted replaced
10:63f6653b094e 12:955b2324c1bf
24 ); 24 );
25 25
26 $parser->parse($in); 26 $parser->parse($in);
27 } 27 }
28 28
29 sub ParseFile {
30 my ($this,$in) = @_;
31
32 my $parser = new XML::Parser(
33 Handlers => {
34 Start => sub {shift; goto &OnStart($this,@_)},
35 End => sub {shift; goto &OnEnd($this,@_)},
36 Char => sub {shift; goto &OnChar($this,@_)}
37 }
38 );
39
40 $parser->parsefile($in);
41 }
42
43
29 sub OnBegin { 44 sub OnBegin {
30 my ($this,$element,%attrs) = @_; 45 my ($this,$element,%attrs) = @_;
31 46
32 $this->{$_current} = $this->Navigator->CreateAndNavigate($element,%attrs); 47 $this->{$_current} = $this->Navigator->NavigateCreate($element,%attrs);
33 } 48 }
34 49
35 sub OnEnd { 50 sub OnEnd {
36 my ($this,$element) = @_; 51 my ($this,$element) = @_;
37 52
43 58
44 $this->{$_current}->nodeValue($this->{$_current}->nodeValue . $val); 59 $this->{$_current}->nodeValue($this->{$_current}->nodeValue . $val);
45 } 60 }
46 61
47 1; 62 1;
63
64 __END__
65
66 =pod
67
68 =head1 SYNOPSIS
69
70 my $reader = new IMPL::DOM::XMLReader(Navigator => $DomBuilder);
71 my $obj = $reader->parsefile("data.xml");
72
73 =head2 DESCRIPTION
74
75 , .
76 .
77
78 C<NavigateCreate> C<Back>
79
80 =cut