jccunning has asked for the wisdom of the Perl Monks concerning the following question:
For example, for values element I would like to get list that tells me values element is in members element which is in enums element, etc. I get error cannot locate object method ancestors.#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $string = "\n <files name=\"Common.h\">\n <enums>\n <membe +rs kind=\"enum\" name=\"PermissionLevel\" protection=\"public\" stati +c=\"no\" virtualness=\"non_virtual\">\n <values initializer=\" + 99\" name=\"PERMISSION_PUBLIC\"></values>\n <values initializ +er=\" 98\" name=\"PERMISSION_NDA\"></values>\n </members>\n + <members kind=\"enum\" name=\"RegisterType\" protection=\"public\" s +tatic=\"no\" virtualness=\"non_virtual\">\n <values initialize +r=\" 4\" name=\"REGISTER_PCI\"></values>\n </members>\n </enu +ms>\n <functions>\n <members const=\"no\" kind=\"function\" n +ame=\"Compare\" protection=\"public\" static=\"no\" type=\"bool\" vir +tualness=\"non_virtual\" volatile=\"no\">\n <parameters declar +ation_name=\"first\" type=\"T\"/>\n <parameters declaration_na +me=\"second\" type=\"T\"/>\n </members>\n </functions>\n </f +iles>"; print $string; my $twig = XML::Twig->new; $twig->parse( $string ); my @names = $twig->ancestors('values'); print @names;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: getting ancestors of element
by philiprbrenan (Monk) on Aug 30, 2012 at 19:23 UTC | |
by jccunning (Acolyte) on Aug 31, 2012 at 15:09 UTC | |
by Athanasius (Archbishop) on Aug 31, 2012 at 15:25 UTC | |
by jccunning (Acolyte) on Aug 31, 2012 at 17:51 UTC | |
by philiprbrenan (Monk) on Aug 31, 2012 at 21:24 UTC | |
by jccunning (Acolyte) on Sep 08, 2012 at 16:40 UTC | |
by philiprbrenan (Monk) on Sep 08, 2012 at 17:12 UTC | |
| |
by jccunning (Acolyte) on Sep 12, 2012 at 15:58 UTC | |
Re: getting ancestors of element
by Anonymous Monk on Aug 30, 2012 at 19:46 UTC | |
Re: getting ancestors of element
by mertserger (Curate) on Aug 31, 2012 at 09:12 UTC |