Hi My HTML 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 cgi script 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();
The output that i am getting is
<opt Boolean="true" blue="1" red="1" sample_text="ak" submit="submit"/ +>
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.

In reply to Formatting XML to tree by mailmeakhila

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.