(操作系統Pro中,的ActivePerl 5.10.1和XML-SAX 0.96使用)XML-SAX錯誤:沒有一個數組引用
MyXML.xml因爲這
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<subItem>
<bib>0006</bib>
<name>Stanley Cheruiyot Teimet</name>
<team>肯尼亞</team>
<time>2:17:59</time>
<rank>1</rank>
<comment />
<gender>Male</gender>
<distance>Full</distance>
<year>2010</year>
</subItem>
</DocumentElement>
MyPerl.pl
#!/usr/bin/perl -w
use strict;
use XML::Simple;
use Data::Dumper;
use utf8;
open FILE, ">myXML.txt" or die $!;
my $tree = XMLin('./myXML.xml');
print Dumper($tree);
print FILE "\n";
for (my $i = 0; $i < 1; $i++)
{
print FILE "('$tree->{subItem}->[$i]->{distance}')";
}
close FILE;
輸出:
D:\learning\perl\im>mar.pl
$VAR1 = {
'subItem' => {
'distance' => 'Full',
'time' => '2:17:59',
'name' => 'Stanley Cheruiyot Teimet',
'bib' => '0006',
'comment' => {},
'team' => '肯尼亞',
'rank' => '1',
'year' => '2010',
'gender' => 'Male'
}
};
Not an ARRAY reference at D:\learning\perl\im\mar.pl line 41.
我不知道是什麼個數組引用意味着什麼? Dumper()
工作正常。但不能將數據打印到TXT文件。
實際上,示例代碼在幾天前運行良好,然後我記得我從V5升級了我的Komodo Edit。到最新的V6。
今天,我只是試圖改進腳本,在開始階段,我修復了另一個錯誤。 「無法找到ParserDetails.ini」谷歌幫助。 (我沒有得到錯誤!)
但現在我得到ARRAY參考錯誤。我剛剛通過PPM重新安裝了我的XML-SAX。它仍然不起作用。
先生您好,您的代碼工作得很好。最後,我發現我的原始代碼也適用於只有用Caps Letters命名的Xml element subItem。像* bib * - > * Bib *; *姓名* - > *姓名*。 Bib和Name來自我的Excel文件。我不知道特殊的Caps Naming規則。這就是我遇到這種麻煩的原因。無論如何,謝謝你,你教過我'FourceArray'。 – 2010-11-11 05:16:26