XML::Twig question
- From: goldtech <goldtech@xxxxxxxxxxxxx>
- Date: Sun, 23 Dec 2007 11:25:11 -0800 (PST)
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
.
- Follow-Ups:
- Re: XML::Twig question
- From: mirod
- Re: XML::Twig question
- Prev by Date: Tie::YAML doesn't write to tmp file first?
- Next by Date: Win32 OLE PS - Resize image
- Previous by thread: Tie::YAML doesn't write to tmp file first?
- Next by thread: Re: XML::Twig question
- Index(es):