|
Posted by goldtech on December 23, 2007, 2:25 pm
Please log in for more thread options
Hi,
Trying this but only "aaa" outputs not "bbb". What's fix? I'm new to
XML and Perl - help appreciated.
xml file:
<?xml version='1.0'?>
<config>
<attrbs>
<attrb>aaa</attrb>
<attrb>bbb</attrb>
</attrbs>
</config>
perl file:
#!/usr/bin/perl -w
use strict;
use XML::Twig;
my $twig= XML::Twig->new( twig_roots => {'/config/attrbs' =>
\&do_attrb});
$twig->parsefile( "xmlt1.xml");
$twig->purge();
sub do_attrb {
my($a1) = $_->find_nodes("attrb");
print $a1->text, "\n";
}
output:
aaa
|