On Jun 25, 3:47 am, [EMAIL PROTECTED] (Mike Blezien) wrote: > I need to parse a fairly largeXMLresponse file and would like some suggestions > on whichXMLmodule would work the best. We've been using theXML::Simple > module, but I don't think that's the right one for the job. Below is theXML > file we need to parse. In particular getting the data from the elements within > the <message></message> > Would theXML::Twigmodule work better for this ?? Any suggestion would be much > appreciated.
Hi Mike, XML::Twig would probably work fine, you can for example do XML::Twig->new( twig_roots => { message => sub { push @messages, $_- >text; $_->purge;}, },) ->parsefile( 'file.xml'); message texts will be in @messages If you need more information than just the text of the message elements, then you can use twig_handlers instead of twig_roots, look at the docs for the difference. That said if the files are the size of your example, that's really small, so there should be no need to switch from a module that loads the entire file in memory. OTOH if message elements can contain mixed content (embedded markup like <b> for example), then that would be a reason to avoid XML::Simple. I hope that helps. -- mirod -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/