#! /usr/bin/perl
#
# xml_perl_update.pl
#
# May/20/2011
# ---------------------------------------------------------------------
#
use strict;
use warnings;
#
use Encode;
use JSON;
use CGI qw (:standard);
#
use lib '/var/www/data_base/common/perl_common';
use cgi_manipulate;
use text_manipulate;
use xml_manipulate;
use file_io;
#
my $file_xml = "/var/tmp/xml_file/cities.xml";
#
my $str_xml = file_io::string_read_proc ($file_xml);
#
my %dict_aa = xml_manipulate::xml_to_dict_proc ($str_xml);
#
print "Content-type: text/html\n\n";
#
my @arry_bb = cgi_manipulate::parse_parameter ();
#
print "*** text_perl_update.pl *** start ***
";
#
my $it=0;
foreach (@{$arry_bb[0]})
{
my $id = $arry_bb[0][$it]->{id};
my $population = $arry_bb[0][$it]->{population};
print "$id $population
";
%dict_aa = text_manipulate::dict_update_proc ($id,$population,%dict_aa);
$it++;
}
#
my $xml_str = xml_manipulate::dict_to_xml_proc (%dict_aa);
file_io::string_write_proc ($file_xml,encode ('utf-8',$xml_str));
#
print "*** xml_perl_update.pl *** end ***
";
#
# ---------------------------------------------------------------------
#