ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: XML::Twig beginner
by Andreas Pürzer other posts by this author
Jun 20 2006 12:27PM messages near this date
view in the new Beta List Site
Re: XML::Twig beginner | Re: XML::Twig beginner
& XSLT Ying Liu schrieb:
>  Andreas Pürzer schrieb:
> > TIMTOWTDI, as always.
> > 
> > One Way:
> > my $first_process = $twig->first_elt('processName');
> > print $_->text, "\n" for
> >     ( $first_process, $first_process->next_sibling );
> > 
> > 
>  XML::Twig::Elt should be part of XML::Twig, right? I installed the XML::Twig package by Ac
tivePerl and it cannot find the method first_elt(). Any way, I will use TwigRoots to extract
 the interest tags. 

Please note that you will not find a (XML::Twig::)Elt.pm, because
package XML::Twig::Elt lives inside Twig.pm! Furthermore, please note
also that first_elt() is not a method of XML::Twig::Elt, but of XML::Twig!

Did you copy & paste or retype my suggestions? I suspect you retyped and
called first_elt() on $root, which will not work (obviously :-> ) because
$root is a XML::Twig::Elt (obtained from calling root() on $twig) and,
as you noticed, there is no sub first_elt in XML::Twig::Elt.

If you look again at the examples, you will surely note that the first
one uses $twig (a XML::Twig Object), whereas the other two use $root (a
XML::Twig::Elt Object). I hope this clarifies things a little bit.
> > 
> > Another Way:
> > my @processes = $root->children('ProcessNames');
> > for ( @processes ) {
> >     print $_->text, "\n" for $_->children;
> > }
> > 
> > Yet Another Way:
> > my @names = $root->descendants('processName');
> > print $_->text, "\n" for @names;
> > 
>  The 2nd and 3rd method works. Thank you.

You are very welcome.

>  
>  Ying
>  

Andreas Pürzer

-- 
perl -mAcme::JAPH

_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Ying Liu
Ying Liu
Andreas P?rzer
Ying Liu
Andreas Pürzer
Ying Liu
Andreas Pürzer
Andreas Pürzer
Ying Liu

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved