<span style="font-family:courier new,monospace"><br>(Note that I've also posted this to PerlMonks.)<br><br>I've been using XML::Simple for some very simple XML and until yesterday</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">it was working the way I expected... till I got bitten with the following example:</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">use XML::Simple;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">use Data::Dumper;</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">my $x =<<EOF;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  <stuff name="me"></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">   <obj class="myclass"></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">       <set name="key1">a</set></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">       <set name="key2"></set></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">   </obj></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">   <obj class="myclass"></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">       <set name="key1">a</set></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">       <set name="key2">b</set></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">   </obj></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace"></stuff></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">EOF</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">$x = XMLin(</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">   $x,</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">   #SuppressEmpty => '',</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">   ForceArray => 1,</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">   ContentKey => '-content',</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">print Dumper(\$x);</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$VAR1 = \{</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">           'obj' => [</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                    {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                      'class' => 'myclass',</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                      'set' => {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                               'key2' => {},</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                               'key1' => {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                                         'content' => 'a'</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                                       }</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                             }</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                    },</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                    {</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                      'class' => 'myclass',</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                      'set' => {</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                               'key2' => 'b',</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                               'key1' => 'a'</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                             }</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                    }</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                  ],</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">           'name' => 'me'</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">         };</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Here I've provided two 'objects', one object has an element that<br>

has an empty or value is blank. As a result the hash that's returned<br>is formatted differently than when _all_ attributes are provided.<br>What I expected was the latter like:</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">'key2' => 'b',</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">'key1' => 'a'</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">but where there is an 'empty' attribute everything changes to a hash<br>(and with the 'content' sub-element). That's what I thought the<br>

ForceArray and ContentKey was supposed to suppress; and the<br>ContentKey does do it!... but only when all fields are populated.</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">I thought SuppressEmpty would do it, but it doesn't.</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">What am I missing?</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">TIA<br>Fulko<br><br></span>