In the past I sometimes used XML::Tiny and I found it perfect for the job. Agreed, I had to struggle only with very little and under-control XML, so I knew I could do without a full-fledged XML Parser.

On the flip side, this rating by Aristotle has always bugged me. I respect Aristotle's opinion a lot, hence this was sufficient for me to look for alternatives... just in case XML::Tiny failed me (which didn't happen so far, anyway).

I've been quite disappointed by XML::Parser::Lite as suggested though. Here's a little example script condensing my findings:

#!/usr/bin/env wrapperl use strict; use warnings; use XML::Parser::Lite; use XML::Parser; use XML::Tiny (); my $xml = <<'END'; <?xml version="1.0"?> <what> <ever><<![CDATA[&foo <=> &bar]]>></ever> </what> END $" = '], ['; my ($what_ever, $collect); my %handler_for = ( Init => sub { $collect = $what_ever = ''; }, Start => sub { $collect = ($_[1] eq 'ever'); }, Char => sub { $what_ever .= $_[1] if $collect; }, End => sub { $collect = '' }, ); print "perl $]

"; print "XML----------------

$xml-------------------

"; for my $class (qw< XML::Parser XML::Parser::Lite >) { my $version = do { no strict 'refs'; ${$class . '::VERSION'}; }; print "$class $version

"; my $parser = $class->new(); $parser->setHandlers(%handler_for); $parser->parse($xml); print " what/ever => [$what_ever]

"; } ## end for my $class (qw< XML::Parser XML::Parser::Lite >) open my $fh, '<', \$xml or die "$!"; my $doc = XML::Tiny::parsefile($fh); print "XML::Tiny $XML::Tiny::VERSION

"; print " what/ever => [$doc->[0]{content}[0]{content}[0]{content}]

";

(If you're wondering about what's that thing in the hash-bang, you can read about it here)

I threw XML::Parser in just to have a control group. Let's run it:

perl 5.018001 XML---------------- <?xml version="1.0"?> <what> <ever><<![CDATA[&foo <=> &bar]]>></ever> </what> ------------------- XML::Parser 2.44 what/ever => [<&foo <=> &bar>] XML::Parser::Lite 0.721 what/ever => [<>] XML::Tiny 2.06 what/ever => [<&foo <=> &bar>]

So, it seems that CDATA sections aren't handled well by XML::Parser::Lite, which is a bit surprising considering that it is considered the implementation of a complete XML parser.

The module is based on this article from 1998, which seems to support CDATA (at least at a shallow inspection). Maybe the translation into Perl code failed at some point?

Update 1 (2016-01-24 09:02:25): Looking at the big regexp in XML::Parser::Lite, it is matching the CDATA but simply discarding it away. Compare the following lines:

my $CDATA_CE = "$UntilRSBs(?:[^\\]>]$UntilRSBs)*>"; #... my $PI_CE = "($Name(?:$PI_Tail))>(?{${package}::_xmldecl(\$5)})";