XML::Parser::Style::Objects
的手冊頁很糟糕。一個簡單的hello世界風格的程序會真的有幫助。如何使用XML :: Parser和Style =>'Objects'
我真的很想做這樣的事情:(當然不是真正的代碼)
use XML::Parser;
my $p = XML::Parser->new(Style => 'Objects', Pkg => 'MyNode');
my $tree = $p->parsefile('foo.xml');
$tree->doSomething();
MyNode::doSomething() {
my $self = shift;
print "This is a normal node";
for $kid ($self->Kids)
{
$kid->doSomething();
}
}
MyNode::special::doSomething() {
my $self = shift;
print "This is a special node";
}