spencerr1 has asked for the wisdom of the Perl Monks concerning the following question:
This probably is not the best way to get form results to XML.
But the challenge I'm having is I would like to be able to capture mulitiple same name keys. Example
Plese enter your birth date
<INPUT TYPE="text" SIZE=30 NAME=Birthdate>
Plese enter your birth date
<INPUT TYPE="text" SIZE=30 NAME=Birthdate>
It's a long form and these same name keys are throughout the form
I made it this far in the code capturing mulitple same names
After decoding %xy:Name=Mark Shortt&Salary=$5555.00&Birthdate=04/18/58&Birthdate=04/19/59
--------------------------------------------------------------------------------After decoding + and &:
<response>
<Salary>$5555.00</Salary>
<Birthdate>04/19/59</Birthdate>
<Name>Mark Shortt</Name>
</response>
# Extracting the + and & and creating key/value pairs
@key_value=split(/&/, $inputstring);
foreach $pair ( @key_value){
($key, $value) = split(/=/, $pair);>/p>
$input{$key} = $value; # Creating a hash
},
# After decoding
print "-" x 80, "
";
print "After decoding + and &:
";
print "<response>
";
while(($key, $value)=each(%input)){
print "<$key>$value</$key>
";
}
print "</response>
"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI form results to XML
by Your Mother (Archbishop) on Feb 16, 2013 at 22:26 UTC | |
by 7stud (Deacon) on Feb 17, 2013 at 01:29 UTC | |
by spencerr1 (Novice) on Feb 17, 2013 at 17:04 UTC | |
by Anonymous Monk on Feb 17, 2013 at 17:12 UTC | |
by Anonymous Monk on Feb 17, 2013 at 19:22 UTC | |
by spencerr1 (Novice) on Feb 17, 2013 at 02:54 UTC | |
by spencerr1 (Novice) on Feb 17, 2013 at 00:21 UTC | |
|
Re: CGI form results to XML
by Your Mother (Archbishop) on Feb 17, 2013 at 21:08 UTC | |
by spencerr1 (Novice) on Feb 17, 2013 at 22:07 UTC | |
|
Re: CGI form results to XML
by Anonymous Monk on Feb 18, 2013 at 08:08 UTC | |
by Your Mother (Archbishop) on Feb 19, 2013 at 04:45 UTC | |
by Anonymous Monk on Feb 19, 2013 at 02:03 UTC |