in reply to force elements in XML::Smart

XML::Smart seems just a bit too clever at times. You may like XML::Maker a bit better:

use strict; use warnings; use XML::Maker; my $xml = XML::Maker->new ('Body'); my $foo = $xml->subtag ('Foo'); $foo->subtag ('Bar'); print $xml->make ();

Prints:

<Body><Foo>Bar</Foo></Body>

or an interesting alternative is to use XML::Spew:

use strict; use warnings; package My::Spew; use XML::Spew; use base 'XML::Spew'; __PACKAGE__->_tags(qw/Body Foo/); package main; my $spew = My::Spew->_new (); print $spew->Body ($spew->Foo ('Bar'));

which generates the same output.


DWIM is Perl's answer to Gödel