rpike has asked for the wisdom of the Perl Monks concerning the following question:
After write I get<?xml version="1.0" encoding="UTF-8"?> <mainTag> <items> <nextSessionID>1000</nextSessionID> </items> </mainTag>
The segment of the program that deals with the XML document being read in and written out.<?xml version='1.0'?> <items nextSessionID="1001" />
my $xmlSimp = XML::Simple->new(); my $xmlCont = $xmlSimp->XMLin($xmlPath); my $varIn = ""; our %xmlHash; foreach my $keyI (keys (%{$xmlCont->{"items"}})) { $varIn = $xmlCont->{"items"}->{$keyI}; $xmlHash{$keyI} = $varIn; if ($keyI eq "nextSessionID") { $xmlCont->{"items"}->{$keyI} = ++$varIn; } } my $tmpOut = $xmlSimp->XMLout($xmlCont, KeepRoot => 1, OutputFile => $xmlPath, XMLDecl => "<?xml version='1.0'?>" );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem saving XML
by Corion (Patriarch) on May 11, 2012 at 16:07 UTC | |
by rpike (Scribe) on May 11, 2012 at 16:27 UTC | |
by Corion (Patriarch) on May 11, 2012 at 20:58 UTC |