use strict; use warnings; no warnings 'uninitialized'; use XML::Rules; my $parser = XML::Rules->new( stripspaces => 7, rules => { sep => '== ', # same as sub { return ' ' } key => sub {return " <b>$_[1]->{_content}</b> "}, FIELD => 'content by NAME', HIT => 'pass', }, ); my $data = $parser->parse(\*DATA); use Data::Dumper; print Dumper($data); __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>
You'd have to add rules for other tags that appear in your XML! XML::Rules is pure Perl, built on top of XML::Parser so you will have no problem installing it in your home directory or alongside the script.
Jenda
Enoch was right!
Enjoy the last years of Rome.
In reply to Re: XML Parsing question
by Jenda
in thread XML Parsing question
by chtaylo2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |