[Chicago-talk] XML::Simple MXLout SuppressEmpty

tiger peng tigerpeng2001 at yahoo.com
Wed Sep 27 12:59:50 PDT 2006


Hello all,

Is there simple way to avoid an empty hash being shown
up as an empty element in XML with XML::Simple?
According to perldoc XML::Simple, the SuppressEmpty
only work for undef in XMLout.

print Dumper($tree);
print XMLout($tree, SuppressEmpty => 1);  

$VAR1 = {
  'category' => {
    '301994' => {
      'level' => 2,
      'categroy' => {},
      'name' => Furniture',
      'code' => '301994'
      }
    }
};
<opt>
  <category name="Furniture" code="301994" level="2">
    <categroy></categroy>
  </category>
</opt>

#Here is my ugly work-around: 
 print XMLout(XMLin(XMLout($tree), SuppressEmpty =>
1));
<opt>
  <category name="Furniture" code="301994" level="2"
/>
</opt>



More information about the Chicago-talk mailing list