Try to run it first.

I had even though I didn't need to do so in this case. I'm quite familiar with what KeyAttr does.

And I'm quite familiar with how to use it properly. "If you do not want folding on input or unfolding on output you must setting this option to an empty list to disable the feature." (empahsis mine). Said list is passed in an array ("KeyAttr => [ list ]").

As whether that's the desired result, I would rather allow different opinion here.

The OP is quite clear what he wants from the second XML snippet ("I would like to have an output like below"). Running your code produces the exact same output as without KeyAttr for this snippet.

With default KeyAttr:

$VAR1 = { 'type' => { 'report' => 'Dummy1', 'name' => 'default' } };

With empty KeyAttr:

$VAR1 = { 'type' => { 'report' => 'Dummy1', 'name' => 'default' } };

Not only did you not fix what the OP asked for you to fix, you broke the code for the case where it used to work. The OP is quite clear that he's "getting proper result" for the first XML snippet. The result you attached shows you broke that.


In reply to Re^4: XML::Simple parsing into a hash wierd behaviour by ikegami
in thread XML::Simple parsing into a hash wierd behaviour by jthomas

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.