DrSax has asked for the wisdom of the Perl Monks concerning the following question:
A snippet that is *like* my code:<log> <msg> <error name="ID not found" /> <request name="myRequest"/> </msg> </log>
The output of this is:# Begin code my $handler = { 'log/msg/error' => \&mysub }; my $twig = Twig->new( TwigRoots => { 'log/msg' => 1 }, TwigHandlers => $handler }); # The handler should only be invoked when an error exists sub mysub { my ($twig, $elt) = @_; $elt->parent()->parent()->print; $twig->purge; } #End code
No matter what I do, I can't see the "request" that is part of the original TwigRoot. I have tried using parent()->sibling("request") and other things, such as parent->parent->next_child("request"). It appears that only the sub-elements are passed in to $twig. Good thoughts are appreciated... DrSax<log><msg><error name="ID not found" /></msg></log>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Twig - can't find my uncle!
by merlyn (Sage) on May 23, 2001 at 03:17 UTC | |
by mirod (Canon) on May 24, 2001 at 18:06 UTC | |
by DrSax (Sexton) on May 23, 2001 at 07:11 UTC | |
|
Re: XML::Twig - can't find my uncle!
by mirod (Canon) on May 23, 2001 at 16:03 UTC | |
|
Re: XML::Twig - can't find my uncle!
by aardvark (Pilgrim) on May 23, 2001 at 04:21 UTC | |
by DrSax (Sexton) on May 23, 2001 at 07:15 UTC | |
by aardvark (Pilgrim) on May 23, 2001 at 09:02 UTC | |
|
Re: XML::Twig - can't find my uncle!
by traveler (Parson) on May 23, 2001 at 02:01 UTC |