in reply to Re^4: XML::Twig Question
in thread XML::Twig Question
I can't make a lot of sense of the documentation either. However the following code may help:
use warnings; use strict; use XML::Twig; my $filtername = 'Advanced Perl Programming'; my $books_tree= new XML::Twig(twig_roots => {Title => \&FixName}); $books_tree->parse(join "", <DATA>); #$books_tree->set_att(Name => 'Advanced Perl'); sub FixName { my ($p1, $p2) = @_; my %node = %$p2; print $node{"att"}{"Name"}."\n"; }
__DATA__ <Books> <Titles Mode="List"> <Title Name="Programming Perl"/> <Title Name="Advanced Perl Programming"/> <Title Name="Learning Perl on Win32 Systems"/> </Titles> </Books> Programming Perl Advanced Perl Programming Learning Perl on Win32 Systems
|
|---|