3

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.

RobEarl
  • 7,862
  • 6
  • 35
  • 50
Scotti
  • 289
  • 4
  • 9

2 Answers2

7

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.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • 1
    The warning comes from XML::Parser, not XML::Simple. It [was fixed](https://rt.cpan.org/Ticket/Display.html?id=67207) in version 2.41. – cjm Aug 22 '11 at 16:31
1

The warning actually comes from an out of date XML::Simple module:

http://www.nntp.perl.org/group/perl.perl5.porters/2011/04/msg171611.html

QGM
  • 11
  • 1