in reply to XML Parsing question

I'm a fan of XML::Twig.

This...
use XML::Twig; my $data; { undef $/; $data = <DATA>; } my $XML = XML::Twig->new; $XML->parse($data); print $XML->root->children_text; __DATA__ <HIT> <FIELD NAME="body"> <sep /> Self-Archiving E-mail Messages in <key>Outlook</key> The following e-mail self-archiving <sep /> create an Archive folder/.pst file. See <key>Outlook</key> 2003 .pst file Management for instruction <sep /> your messages. Select your <key>Files</key> (This refers to your primary... <sep /> </FIELD> </HIT>
...outputs this:
Self-Archiving E-mail Messages in Outlook The following e-mail self-archiving create an Archive folder/.pst file. See Outlook 2003 .pst file Management for instruction your messages. Select your Files (This refers to your primary...

Replies are listed 'Best First'.
Re^2: XML Parsing question
by chtaylo2 (Initiate) on Jul 08, 2010 at 17:27 UTC
    I like Twig as well, however I'm on a enterprise system so have to stick with XML::Simple. Any idea how to do it with that module ?
      Nope.

      Perhaps this horribly evil concoction?
      use Data::Dumper; my $data; { undef $/; $data = <DATA>; } my @text = grep { /^\S/ } map { s/^\s+|\s+$//g; $_ } $data =~ />([^<>] ++)/g; print Dumper(\@text); __DATA__ <HIT> <FIELD NAME="body"> <sep /> Self-Archiving E-mail Messages in <key>Outlook</key> The following e-mail self-archiving <sep /> create an Archive folder/.pst file. See <key>Outlook</key> 2003 .pst file Management for instruction <sep /> your messages. Select your <key>Files</key> (This refers to your primary... <sep /> </FIELD> </HIT>