in reply to That's not a simple parser
in thread XML::Parser Tutorial

Please see also XML::LibXML::Simple for a handy replacement for XML::Simple:

#!/usr/bin/env perl use warnings; use strict; use Data::Dump; use XML::LibXML::Simple qw(XMLin); $/ = undef; my $xml = <DATA>; my $ref = XMLin $xml; # dd $ref; foreach my $msg (@{$ref->{'message'}}) { my $h = substr($msg->{'time'}, 8, 2); my $n = substr($msg->{'time'}, 10, 2); my $author = $msg->{'content'} =~ s/^\/me// ? $msg->{'author'} : " +<$msg->{'author'}>"; print "$h:$n $author: $msg->{'content'}\n"; } __END__ <CHATTER><INFO site="http://perlmonks.org" sitename="Perl Monks">Rende +red by the Chatterbox XML Ticker</INFO><message author="OeufMayo" tim +e="20010228112952">test</message><message author="deprecated" time="2 +0010228113142">pong</message><message author="OeufMayo" time="2001022 +8113153">/me test again; :)</message><message author="OeufMayo" time= +"20010228113255">&lt;a href="#"&gt;please note the use of HTML tags&l +t;/a&gt;</message></CHATTER>

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re^2: That's not a simple parser
by Anonymous Monk on Feb 02, 2015 at 08:16 UTC

    Please see also XML::LibXML::Simple for a handy replacement for XML::Simple:

    :) nope, XML::Rules is a handy replacement for XML::Simple

      Sure yes, from the view of Jenda ;-)

      BTW, i didn't know XML::Rules, thank you for the hint.

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»