I want to output a hash to xml. I'm using xml::simple, but the formatting is not quite what I would expect/desire". A dumper of the hash shows:
$VAR1 = {
'xfire' => {
'summary' => 1,
'config' => 1
}
};
My code will output:
<qa_logs>
<xfire config="1" summary="1" />
</qa_logs>
What I want is:
<qa_logs>
<xfire>
<config>1</config>
<summary>1</summary>
</xfire>
</qa_logs>
Is there an easy way to do this? Do I need to build my hash differently?
Thanks!
(BTW: I also would like to append to a file rather than create a new one. I guess the best way to do this is to open the file to append, and then not specify OutputFile for XMLout).
Code snippet:
XMLout(\%qa_logs, OutputFile => "newfile.xml", RootName => 'qa_logs');
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.