The cgi script is<html><head><title>Report</title></head> <body> <form action="http://localhost/cgi-bin/temp.txt" method="POST"> <br> Text Box: <br> <input type="text" name="sample_text"> <br> <br> Check Box: <br> <input type="checkbox" name="red" value=1>Red<br> <br> <input type="checkbox" name="blue" value=1>Blue<br> <br> Radio Button <br> <input type="radio" name="Boolean" value="true">True<br> <br> <input type="radio" name="Boolean" value="false">False<br> <br> <input type = "submit" name = "submit" value = "submit"/> </form> </body></html>
The output that i am getting is#! /usr/bin/perl -w print "Content-type: text/html\n\n"; use CGI; use IO::File; use XML::Simple; my %form; my $cgi = CGI->new; foreach my $field ($cgi->param()) { $form{$field} = $cgi->param($field); } my $hash_ref = \%form; my $output = new IO::File(">out.xml"); my $xml = XML::Simple::XMLout($hash_ref, OutputFile => $output); $output->close();
This is how i want it to look like: <code> <opt> <boolean>true</boolean> <blue>1</blue> <red>1</red> <sample_text>ak</sample_text> <submit>submit</submit> </opt> Can anyone help to get the output i want.<opt Boolean="true" blue="1" red="1" sample_text="ak" submit="submit"/ +>
In reply to Formatting XML to tree by mailmeakhila
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |