poj#!perl use strict; use XML::Twig; my $xml = do { local $/; <DATA> }; my $twig = new XML::Twig( twig_handlers =>{ class => \&class}, ); $twig->parse($xml); sub class { my ($t,$elt) = @_; for my $shape ($elt->children){ $shape->set_att('class',$elt->att('id')); $shape->print; print "\n"; } } __DATA__ <data> <class id="abc"> <polygon coordinates=".."/> <polygon coordinates=".."/> <rectangle coordinates=".."/> </class> <class id="def"> <polygon coordinates=".."/> <rectangle coordinates=".."/> <rectangle coordinates=".."/> </class> </data>
In reply to Re: Creation of Hash necessary?
by poj
in thread Creation of Hash necessary?
by sandorado
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |