Thanks wind, Please have a look at this
use XML::Simple; use strict; use warnings; my ($id, $value); #group 1 paramters $id = "ID1"; $value = "Recording INformation"; getParameter($id, $value); $id = "ID2"; $value = "Pausing INformation Record "; getParameter($id, $value); $value = "Information Loading"; getParameter($id, $value); $value = "Information loading Complete"; #From here group 2 parameter starts my $id = 2; $value = "Picture loading"; getParameter($id, $value); my $id = 3; $value = "Picture loading complete"; getParameter($id, $value); #Group 2 parameters end. sub getParameter { my ( $id,$value) = @_; my $hash = { 'Key' => $id, 'Value' => $value }; my $xml = { Parameter => [] }; push( @{ $xml->{Parameter} } , { key => $hash->{Key}, content => $hash->{Value} } ); print XMLout( $xml, RootName => 'Parameter' ); }

Right now, the output that i get is something like
<Parameter key="ID1">Recording INformation</Parameter> <Parameter key="ID2">Pausing INformation Record</Parameter> <Parameter key="ID2">Information Loading</Parameter> <Parameter key="ID2">Information loading Complete</Parameter>
If I need something like
<Parameters> - <ParameterGroup ID="Group1"> <Parameter key="Key1">Some Value</Parameter> <Parameter key="Key2">Some Value</Parameter> <Parameter key="Key3">Some Value</Parameter> </ParameterGroup> - <ParameterGroup ID="Group2"> <Parameter key="Key1">Some Value</Parameter> <Parameter key="Key2">Some Value</Parameter> <Parameter key="Key3">Some Value</Parameter> </ParameterGroup> </Parameters>
What do I have to do? Thanks

In reply to Re^2: Which XML module to use for this scenario? by Perllace
in thread Which XML module to use for this scenario? by Perllace

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.