Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks, I have a question regarding the nesting.
For the below coding i expected only one list but it gives two list. The input has only one list and and nested list in the list. why it takes that nested list as separate. I dont want that inner list separately, i want only main list with inner list in it. How to do it?
use strict; use XML::Twig; my $file = "1.xml"; my $twig = XML::Twig->new( twig_roots => {'list' => \&list}, pretty_print=> 'indented'); $twig->parsefile($file); sub list { my ($twig, $sec) = @_; $sec->print; }
Input: <?xml version="1.0"?> <camelids> <section> <r>afasdfasdf</r> <section> <list> <list-item>242354</list-item> <list-item>gsdfg <list> <list-item>7989</list-item> <list-item>97989</list-item> </list> </list-item> </list> fasdfas </section> </section> </camelids>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: xml::Twig question
by mirod (Canon) on Nov 09, 2005 at 17:19 UTC |