0
我試着用下面的腳本無法通過包XML定位對象::嫩枝
#!/usr/local/bin/perl
use strict;
use warnings;
use XML::Twig;
my $twig = XML::Twig->new()->parsefile ('test.xml');
print "id;name;description;published\n";
foreach my $row ($twig->results->children('row')) {
print join(";",
$row->first_child_text('id'),
$row->first_child_text('name'),
$row->first_child_text('description'),
$row->first_child_text('published'),
),
"\n";
}
的XML文件轉換爲CSV但我發現了錯誤Can't locate object method "
結果「通過一攬子」 XML ::嫩枝「在perl1.pl線10
這裏是我的XML
<results>
<row>
<id></id>
<name>...</name>
<description>...</description>
<published></published>
</row>
....
</result>
謝謝你的提示 – user5507230
現在我得到這個錯誤不能用string (「XML :: Twig」)作爲HASH ref,而在/usr/local/lib/x86_64-linux-gnu/perl/5.20.2/XML/Parser.pm第224行使用「strict refs」。 at perl1 .pl第6行。 – user5507230
OK。無法回答爲什麼,沒有看到一些代碼。但是......你有在代碼中使用XML :: Twig嗎?因爲這通常表示沒有加載模塊。 – Sobrique