develooper Front page | perl.beginners | Postings from April 2010

not able to get contents from hash after parsing xml

From:
vyomesh Kulkarni
Date:
April 19, 2010 00:38
Subject:
not able to get contents from hash after parsing xml
Message ID:
k2l6a93265a1004190038zd74b98fftdda58715dd6ff440@mail.gmail.com
Have this xml file to parse and code written for the same is

#!/usr/bin/perl

use XML::Simple qw(:strict);
use Data::Dumper;

my $file = 'tc1.xml';
my $data = XMLin($file, ForceArray => 1, KeyAttr =>{},);


#print Dumper($data);

foreach my $TestCase (@{$data->{TestCase}}){
print $TestCase->{Action}->{run_cmd}->[0], "\n"
}

____________________________________________
the sample xml is here.

<TestSuite>
<TestCase name="first">

<Action>
<run_cmd>cmd</run_cmd>
<Args>@arr1</Args>
<Prompt>ok</Prompt>
<Ret_values>reference1</Ret_values>
</Action>

<Action>
<run_cmd>cmd1</run_cmd>
<Args>@arr1</Args>
<Prompt>ok</Prompt>
<Ret_values>reference1</Ret_values>
</Action>

</TestCase>


<TestCase name="second">

<Action>
<run_cmd>cmd2</run_cmd>
<Args>@arr1</Args>
<Prompt>ok</Prompt>
<Ret_values>reference1</Ret_values>
</Action>

<Action>
<run_cmd>some_command</run_cmd>
<Args>@arr2</Args>
<Prompt>ok</Prompt>
<Ret_values>reference1</Ret_values>
</Action>

</TestCase>
</TestSuite>

___________________________________________________

however, I am not able to retrieve the contents of xml. the dumper statement
gives me hash but not able to get individual elements. I am seeing the error
"Out of Memory!" can someone please help me in troubleshooting this issue.

Also, If i do this instead, then out of memory error is gone, but still not
able to get the individual elements.

foreach my $TestCase (@{$data->{TestCase}->{Action}}){
print $TestCase->{Action}->{run_cmd}->[0], "\n"
}



please help.

--
thanks,
vy



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About