#!/usr/bin/perl use XML::Simple; use Data::Dumper;api
@arr = [ {'country'=>'england', 'capital'=>'london'}, {'country'=>'norway', 'capital'=>'oslo'}, {'country'=>'india', 'capital'=>'new delhi'} ];app
my $xml = new XML::Simple (NoAttr=>1, RootName=>'data'); my $data = $xml->XMLout(@arr); #print Dumper($data); print ($data);xml
open (FNS ,"> D:\PerlDemo\ff.xml"); print FNS ($data); close (FNS);it
################################################io
<app name="xmlsimple" author="dorainm" mail="dorainm@gmail.com"> <log version="0.1" date="2009-04-14"> <change>describes about version 0.1</change> </log> <log version="0.2" date="2009-04-15"> <change>describes about version 0.2</change> </log> </app>object
my $conf = XMLin("D:\PerlDemo\parse.xml");date
print "Program \n $conf->{'name'} $conf->{'author'} $conf->{'mail'}\n";perl
my $i = 0; while( $conf->{'log'}->[$i] ) { print "@ $conf->{'log'}->[$i]->{'version'} at " . "$conf->{'log'}->[$i]->{'date'} : " . "$conf->{'log'}->[$i]->{'change'}\n"; $i ++; }im