in reply to Hash to XML with XML::Twig

Does it have to be XML::Twig?

use XML::Rules; my $parser = XML::Rules->new( rules => {}, ); print $parser->ToXML( data => { record => { id => 'B0001', section => [ 'Computer' ], title => [ 'PerlMonks' ], url => { target => '_blank', _content => 'http://www.perlmonks.org', } } }, 0, ' ', );

The unnamed arrays are there to make sure the section and title produce tags and not attributes. Another option would be to use section => {_content => 'Computer'}.

Replies are listed 'Best First'.
Re^2: Hash to XML with XML::Twig
by sureerat (Acolyte) on Dec 02, 2008 at 17:59 UTC
    Hello Jenda,

    Thank you for your reply. XML::Rules is new for me but from your example, it is an easier way to handle my task. It's interesting. I will read more about it. However, just doubt whether XML::Twig can't do the similar way.