Think about Loose Coupling | |
PerlMonks |
Re: Parsing a highly nested XML file correctly and efficiently -- XML::Twigby Discipulus (Canon) |
on Jun 10, 2016 at 09:07 UTC ( [id://1165274]=note: print w/replies, xml ) | Need Help?? |
Hello, so if I understood your desired output, you can simply get the first_children sequentially; like :
This becomes very prolix and repetitive soon, in fact you only need an xpath so for Junk1 you can also: So having a lot of xpath to process the same way you can compatc the code a lot, ending with the following twig_handler
The whole code will be:
with the following output
In addition, when you need to write everytimes to a destination file, you can profit of select $filehandle; Is very useful also because while debugging you can comment it to see at screen the output. HtH L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|