No such thing as a small change | |
PerlMonks |
CGI form results to XMLby spencerr1 (Novice) |
on Feb 16, 2013 at 22:03 UTC ( [id://1019080]=perlquestion: print w/replies, xml ) | Need Help?? |
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>
Back to
Seekers of Perl Wisdom
|
|