Click here to get back home

XML::Twig question

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
XML::Twig question goldtech 12-23-2007
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


Similar ThreadsPosted
XML Twig help April 8, 2005, 2:18 pm
Using XML::Twig December 19, 2005, 4:59 pm
XML::Twig June 9, 2006, 1:50 pm
XML::Twig June 9, 2006, 6:27 pm
Help with XML::Twig xpath syntax, please October 16, 2005, 6:56 pm
XML::Twig parseurl with input Headers/XML January 16, 2005, 10:58 pm
XML::Twig::XPath - strange problem November 10, 2005, 9:44 am
XML::Twig produces double encoded UTF-8 January 4, 2007, 3:36 pm
XML::Twig constructor disregarding map_xmlns - bug in module? August 29, 2004, 1:21 pm
Problem Parsing Huge XML file using XML::Twig April 23, 2007, 10:24 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap