in reply to Problem with CGI::XML

If you are wanting to use the CGI module to produce XML this little script may get you started in the right direction. CGI wasn't made to create XML, but this seems to work fine.
use strict; use CGI::Pretty qw(book chapter); # for pretty XML my $c = new CGI; print $c->book( {-title=>"Programming Perl", -authors=>" Larry Wall, Tom Christian +sen, Jon Orwant"}, $c->chapter({-number=>1},"An Overview of perl"), $c->chapter({-number=>2},"Bits and Pieces"), $c->chapter({-number=>3},"Unary and Binary Operators"), );

output:

<book title="Programming Perl" authors=" Larry Wall, Tom Christiansen, + Jon Orwant"> <chapter number="1"> An Overview of perl </chapter> <chapter number="2"> Bits and Pieces </chapter> <chapter number="3"> Unary and Binary Operators </chapter> </book>



-Silent11

Replies are listed 'Best First'.
(jeffa) 2Re: Problem with CGI::XML
by jeffa (Bishop) on Feb 05, 2003 at 15:53 UTC
    I too have thought that CGI.pm does a pretty nifty job of creating XML with it's dynamic tag-to-sub magic, but ... looks like you created a monster! ;)

    jeffa

    perl -MCGI=foo -le "print foo{bar=>baz},qux"