in reply to Re: empty element with xml::smart
in thread empty element with xml::smart

Installed the module... It actually produces <element/> for empty elements:

use XML::Smart qw( ); my $xml = XML::Smart->new(); $xml->{foo}{bar}{empty} = {}; print scalar $xml->data();
<?xml version="1.0" encoding="iso-8859-1" ?> <?meta name="GENERATOR" content="XML::Smart/1.6.8 Perl/5.008008 [MSWin +32]" ?> <foo> <bar> <empty/> </bar> </foo>

If you use a DTD, then you need to specify the "EMPTY" keyword or else it'll generate <empty></empty> (which is fine cause it means the same thing).

use XML::Smart qw( ); my $xml = XML::Smart->new(); $xml->{foo}{bar}{empty} = {}; $xml->apply_dtd(<<'__EOI__'); <!DOCTYPE foo [ <!ELEMENT foo (bar*)> <!ELEMENT bar (empty*)> <!ELEMENT empty EMPTY> ]> __EOI__ print scalar $xml->data();

Replies are listed 'Best First'.
Re^3: empty element with xml::smart
by makrospex (Initiate) on Mar 18, 2008 at 19:41 UTC
    thanks for the reply/solution. i was trying '' and undef as source values (from the db) for xml::smart, that didnt work the way i expected perl to work. sure, the empty hash, i should have tried that too. thanks for help!