vaibhav.shukla has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to Parse multiple XML and Store the values into hashmap as Key/Value Pair.
I have tried to Parse multiple XML and Store the values into array as my certain fields has duplicate values so I want the unique value of it and store its corresponding values.
Does anyone can suggest me ideas?I am unable to initiate it as I don't know how to store key/value pair in Hashmap. and sample of the XML is
<?xml version="1.0" encoding="utf-8"?> <!-- Configuration for the aero product --> <product name="aero" xsi:noNamespaceSchemaLocation="product.xsd" xmlns +:xsi="http://www.w3.org/2001/XMLSchema-instance"> <productName>Airtime</productName> <licenseName>Airtime_Tool</licenseName> <externalProductIdentifier>10</externalProductIdentifier> <baseCode>AT</baseCode> <released>true</released> <releasePlatforms> <platform>all</platform> </releasePlatforms> <dependsOn> <componentDep name="air"></componentDep> <componentDep name="air"></componentDep> <componentDep name="air"></componentDep> </dependsOn> <requiredProducts> <productDep name="air"></productDep> </requiredProducts> <releaseTypeAndDelivery> <releaseTD releaseType="PVersion" releaseDelivery="DVD"/> <releaseTD releaseType="PVersion" releaseDelivery="Web"/> <releaseTD releaseType="SVersion" releaseDelivery="Web"/> </releaseTypeAndDelivery> </product>
and I only need
<productName>Airtime</productName> <licenseName>Airtime_Tool</licenseName> <externalProductIdentifier>10</externalProductIdentifier> <baseCode>AT</baseCode> <product name =aero>
and I want to make licenseName as key and rest as a Values of it. I have tried it as
Thanks!!!my $xmldata= XMLin($filename); foreach my $licenseName (keys %{$xmldata->{licenseName}}) { print $licenseName . ' is ' . $xmldata->{basecode}->{$basecode +} . $xmldata->{externalProductIdentifier}->{$externalProductIdentifie +r} . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing multiple XML and Store the values into hashmap as Key/Value Pair
by Loops (Curate) on Jul 17, 2013 at 23:42 UTC |