comparison _test/test_xml.pl @ 3:ae61af01bfa5

sync
author cin
date Wed, 23 Oct 2013 01:13:19 +0400
parents
children 8001dc056331
comparison
equal deleted inserted replaced
2:f2a86753b494 3:ae61af01bfa5
1 #!/usr/bin/perl
2 package MyParser;
3
4 use IMPL::declare {
5 base => [
6 'Yours::Parsers::SaxParser' => undef
7 ]
8 };
9
10 sub ProcessRootNode {
11 my ($this,$node) = @_;
12
13 my $handler;
14 my $level = 0;
15 $handler = sub {
16 my ($me,$node) = @_;
17 print ' ' x $level, $node->depth, " ", $node->name,"\n";
18 $level++;
19 $me->ReadChildren($handler);
20 $level--;
21 };
22
23 print "root: \n";
24 $this->ReadChildren($handler);
25 }
26
27 my $text = '<?xml version="1.0"?>
28 <root>
29 <n1></n1>
30 <n2>
31 <w1>asd</w1>
32 </n2>
33 <n3></n3>
34 </root>
35 ';
36
37 MyParser->new()->Parse({
38 string => $text
39 });
40