in reply to Get XML content using XML::Twig module
You could write something like the code below, which is very simple but probably not easily extensible, or write at the Connection level, have just one twig_handler for the connection, extract whichever info you need from the tree for that element, then purge it and be done. The methods used in the code below should help you write a better version.
#!/usr/bin/perl use strict; use warnings; use XML::Twig; XML::Twig->new( twig_handlers => { Sender => sub { print "sender: ", + $_->text, "\n"; }, Receiver => sub { print "receiver: +", $_->text, "\n"; }, FileType => sub { print " file: ", + $_->first_child->tag, "\n"; $_->purge; }, }, ) ->parsefile( "fdata.xml");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Get XML content using XML::Twig module
by Jenda (Abbot) on Apr 22, 2010 at 12:53 UTC |