可能重复:
Why am I getting an “Out of memory” error with Perl's XML::Simple?如何使用Perl解析大型XML文件?
我有这样一个XML文件:
<message>
<c1>
<rrcConnectionSetupComplete>
<rrc-TransactionIdentifier>2</rrc-TransactionIdentifier>
<criticalExtensions>
<c1>
<rrcConnectionSetupComplete-r8>
<selectedPLMN-Identity> 1 </selectedPLMN-Identity>
<dedicatedInfoNAS> 07410109014290112345671000028020000f0 </dedicatedInfoNAS>
</rrcConnectionSetupComplete-r8>
</c1>
</criticalExtensions>
</rrcConnectionSetupComplete>
</c1>
</message>
我使用这样的Perl代码访问XML文件中的数据(我应该坚持这种访问格式)
#!/usr/bin/perl
use strict;
use XML::Simple;
my $xml = new XML::Simple;
my $data = $xml->XMLin("uL-DCCH-Message.xml");
my $rrc_trans_identifier = $data->{'c1'}->{'rrcConnectionSetupComplete'}->{'rrc-TransactionIdentifier'};
print "rrc_trans_id :: $rrc_trans_identifier\n";
my $selected_plmn_id = $data->{c1}->{rrcConnectionSetupComplete}->{criticalExtensions}->{c1}->{'rrcConnectionSetupComplete-r8'}->{'selectedPLMN-Identity'};
print "plmn identity :: $selected_plmn_id\n";
my $rrc_dedicated_info_nas = $data->{c1}->{rrcConnectionSetupComplete}->{criticalExtensions}->{c1}->{'rrcConnectionSetupComplete-r8'}->{dedicatedInfoNAS};
print "dedicated info nas :: $rrc_dedicated_info_nas\n";
产生的输出是,使用XML ::简单工作正常对于较小的XML文件(如图所示在上述输出)
rrc_trans_id :: 2
plmn identity :: 1
dedicated info nas :: 07410109014290112345671000028020000f0
Perl代码。
但是,如果XML文件很大,那么XML :: Simple将无法处理,并显示错误消息Ran out of memory
。
是否有任何其他XML解析器可以使用,以便我可以像上面所显示的类似方式访问XML文件中的元素?
如果还有其他解析器可用,是否可以通过遵循与XML :: Simple相同的约定来给出示例。
你已经问过这个在http://stackoverflow.com/questions/3726197/why-am-i-getting-an-out-of-memory-error-with-perls-xmlsimple - 请重新 - 读你在那里得到的建议。 – Ether 2010-09-17 05:41:44
但我以不明确的方式提出这个问题,这就是为什么我再一次询问确切的场景 – 2010-09-17 06:00:50
所以编辑你的原始问题来澄清。不要垃圾网站。 – Ether 2010-09-17 06:30:09