XML::LibXML is also a good one for general xml parsing/manipulation. -----Original Message----- From: mirod [mailto:[EMAIL PROTECTED] Sent: 26 June 2007 08:47 To: beginners@perl.org Subject: Re: XML Parsing
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/ This e-mail is from the PA Group. For more information, see www.thepagroup.com. This e-mail may contain confidential information. Only the addressee is permitted to read, copy, distribute or otherwise use this email or any attachments. If you have received it in error, please contact the sender immediately. Any opinion expressed in this e-mail is personal to the sender and may not reflect the opinion of the PA Group. Any e-mail reply to this address may be subject to interception or monitoring for operational reasons or for lawful business practices. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/