xml - 使用 Perl XML::Simple 时出现“格式不正确”错误

标签 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-多线程构建的 ActivePerl (v5.14.1)。 我正在尝试在 Win7 上运行此脚本。

最佳答案

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.

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

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

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

关于xml - 使用 Perl XML::Simple 时出现“格式不正确”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7145957/

相关文章:

mysql - 抛出“不是数组引用”错误

perl - DBIx::Class::Schema::Loader 连接到不同机器上的数据库

perl - XML::Parser 拒绝安装

xml - 用于在 XML 中查找和替换标记值的 Perl 代码

java - 首选项库未加载首选项

c# - 从存储过程中获取 XML

java - 从 Xml 数据生成图形的工具

xml - 在根节点中声明命名空间时,xslt 脚本不起作用

perl - 如何在 pod2usage 中指定宽度?

perl - 如何将 Data::Dumper 输出转换回 Perl 数据结构?