Xml – ‘not well-formed’ error using Perl XML::Simple

perlxmlxml-simple

I am trying to run a Perl script to get all the elements of an xml document into an array. The code is as follows:

#!/usr/bin/perl

# Script to illustrate how to parse a simple XML file
# and dump its contents in a Perl hash record.

use strict;
use XML::Simple;

my $xs = new XML::Simple();

my $booklist = $xs->XMLin('./cmn_msg.xml');

print Dumper($data);

When I run this code, I get an error:

Use of tied on a handle without * is deprecated at C:/Perl/lib/XML/Parser/Expat.pm line 447.

not well-formed (invalid token) at line 4, column 14, byte 128 at C:/Perl/lib/XML/Parser.pm line 187

I am using ActivePerl (v5.14.1) built for MSWin32-x86-multi-thread.
I am trying to run this script on Win7.

Best Answer

But when I run this code, I get an error: Use of tied on a handle without * is deprecated at C:/Perl/lib/XML/Parser/Expat.pm line 447.

That sounds like a warning, rather than an error. You have an out of date install of XML::Parser:.

not well-formed (invalid token) at line 4, column 14, byte 128 at C:/Perl/lib/XML/Parser.pm line 187

That says your XML is broken. You need to correct the XML.

Related Topic