Re: XML::Twig beginner
by Ying Liu other posts by this author
Jun 19 2006 3:26PM messages near this date
view in the new Beta List Site
Re: XML::Twig beginner
|
XML::LibXML Catalogs problem
& XSLT Thanks Andreas! Now, I understand why use 'twig_handlers'.
Ying
Andreas P�rzer <pue@[...].net> wrote: Ying Liu schrieb:
> I just started with XML::Twig. Lots of complicated xml files. I test some examples code bu
t didn't work well. There are too many methods in Twig. The following code is a simgple exam
ple. I want to get the text of (ThisIsMySequence) and two records of
(ILikeProcesses, ILikeProcesses2). How to find levels of the xml file? and How to find inte
resting tags. Those XML files are quite long and complicated.
>
> Thanks,
> Ying
>
Welcome to the beautiful World of XML::Twig!
Maybe this will help to get you started:
__CODE__
#!/usr/bin/perl
use warnings;
use strict;
use XML::Twig;
my $xml = join "", ;
my $twig = XML::Twig-> new(
twig_handlers => {
name => sub {
print "Found a ''-Tag, Value: ", $_-> text, "\n";
},
processName => sub {
print "Found a '
'-Tag, Value: ", $_-> text, "\n";
},
},
);
$twig-> parse($xml);
__DATA__
ThisIsMySequence
mbuser
_working
1150231914745
ILikeProcesses
ILikeProcesses2
__CODE_END__
Apart from reading `perldoc XML::Twig` over and over again ( it's worth
it IMHO ), the best advice I can offer is to go here
L and work yourself
through it.
HTH,
Andreas P�rzer
--
perl -mAcme::JAPH
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
Thread:
Ying Liu
Ying Liu
Andreas P?rzer
Ying Liu
Andreas Pürzer
Ying Liu
Andreas Pürzer
Andreas Pürzer
Ying Liu
|