vasuperl has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to access multiple values from XML file in our perl file
by choroba (Cardinal) on Jan 09, 2015 at 12:35 UTC | |
by vasuperl (Acolyte) on Jan 09, 2015 at 13:53 UTC | |
by poj (Abbot) on Jan 09, 2015 at 16:13 UTC | |
by jellisii2 (Hermit) on Jan 09, 2015 at 16:47 UTC | |
by Lotus1 (Vicar) on Jan 09, 2015 at 14:56 UTC | |
|
Re: How to access multiple values from XML file in our perl file
by Corion (Patriarch) on Jan 09, 2015 at 12:04 UTC | |
by vasuperl (Acolyte) on Jan 09, 2015 at 12:15 UTC | |
|
Re: How to access multiple values from XML file in our perl file
by Jenda (Abbot) on Jan 13, 2015 at 13:35 UTC |