使用Perl XML :: Simple时“错误形成”错误

时间:2011-08-22 10:16:50

标签: xml perl xml-simple

我正在尝试运行Perl脚本以将xml文档的所有元素都放入数组中。代码如下:

#!/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);

当我运行此代码时,出现错误:

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

我正在使用为MSWin32-x86-multi-thread构建的ActivePerl(v5.14.1)。 我试图在Win7上运行这个脚本。

2 个答案:

答案 0 :(得分:7)

  

但是当我运行这段代码时,我收到一个错误:在C:/Perl/lib/XML/Parser/Expat.pm第447行弃用了没有*的句柄上的绑定。

这听起来像是警告,而不是错误。您有XML :: Parser的过时安装:。

  

第4行,第14列,C处的字节128 格式不正确(无效令牌)

这表示您的XML已损坏。您需要更正XML。

答案 1 :(得分:0)

警告实际上来自过时的XML :: Simple模块:

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

相关问题