I have one XML file
<MTPconfiguration>
<lteNbrEnbInfo>
<field record="lteNbrEnbInfo">
<key name="enbType" />
<value id="1" />
<key name="enbId"/>
<value id="130560" />
<key name="plmnID" />
<value id="00101" />
</field>
</lteNbrEnbInfo>
</MTPconfiguration>
I am trying to access those multiple keys and values in a loop like the code which i was mentioned below, but it is showing error.
#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
my $XML = XMLin("C:\\Users\\Administrator\\Desktop\\Automation\\VERSIO
+N2\\TC2\\value.xml");
my $MTPconfiguration=$XML->{MTPconfiguration};
my $lteNbrEnbInfo=$MTPconfiguration->{lteNbrEnbInfo};
my $Enbfield=$lteNbrEnbInfo->{field};
print Dumper($Enbfield);
my @field = $Enbfield->{field}->{key};
print "@field \n"
foreach (@($Enbfield->{field})) {
print $_->{key}. "\n";
print $_->{value}. "\n";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.