为什么我会收到“内存不足"的提示? Perl的XML :: Simple错误? [英] Why am I getting an "Out of memory" error with Perl's XML::Simple?
问题描述
已:
大家好,
我有一个这样的XML文件,
I have a XML file like this,
<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文件中的数据(我应该坚持这种访问格式)
I am using Perl code like this to access the data in xml file (i should stick on to this format of accessing)
#!/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";
产生的输出是
rrc_trans_id :: 2
plmn identity :: 1
dedicated info nas :: 07410109014290112345671000028020000f0
使用XML :: Simple的Perl代码在较小的XML文件上正常工作(如上面的输出所示).
Perl code using XML::Simple is working fine for smaller XML files (as shown in the above output).
但是,如果XML文件很大,则XML :: Simple无法处理,并且显示错误消息Ran内存不足.
But If XML file is large, then XML::Simple cannot handle and it is showing error message Ran out of memory.
我的问题是,我还可以使用其他任何XML解析器,以便以与上图所示类似的方式访问XML文件中的元素吗?
My question is, Is there any other XML Parsers i can use, so that i can access the elements in XML file in the similar manner as shown above ???
如果有任何其他解析器可用,任何人都可以通过遵循我对XML :: Simple遵循的相同约定来举一个示例.
If there is any other parsers available, can any one give an example by following the same conventions i am following for XML::Simple..
请帮助我,我为此感到挣扎
Kindly help me, i am struggling with this
推荐答案
在
这将精确地输出您所追求的: This outputs exactly what you were after: 上面为您提供的示例工作,但是在 Above works for the example you provided but there are a few different ways you could achieve the same result in 请不要将这个问题的可接受答案分配给我! Chas&尤金首先出现在现场,为您的问题提供了正确的答案,而布莱恩则给出了普遍存在的答案.
Please don't assign me with the accepted answer for this question! Chas & eugene were first on the scene with the correct answer to your problem and brian followed up with the ubiquitous answer. /I3az/ 这篇关于为什么我会收到“内存不足"的提示? Perl的XML :: Simple错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!rrc_trans_id :: 2
plmn identity :: 1
dedicated info nas :: 07410109014290112345671000028020000f0
重要
XML::Twig
取决于您的确切要求.
XML::Twig
depending on what your exact requirements are.