toxml(3)
NAME
CGI::ToXML - Converts CGI to an XML structure
SYNOPSIS
use CGI::ToXML qw( CGItoXML ); use CGI; my $q = new CGI; my $xml = CGItoXML( $q ); my $xml2 = CGItoXML( $q, exclude => [ qw( password username sessionid ) ] );
DESCRIPTION
Converts a CGI variable (from CGI.pm) to an XML data
structure. While there is currently a similar module,
CGI::XML, by Jonathan Eisenzopf, the outputted XML is not
in a very usable format, given the newer advances in XML
(such as XSLT, XPath, etc). CGI::ToXML aims to correct
this by providing a cleaner XML structure that will be
more useful. The XML is generated from XML::Simple, keep
ing this a 'lightweight' function.
- The module consists of a single function:
- $xml = CGItoXML( $cgi, %options )
- $cgi must be a valid CGI.pm object, and if not, a warning
will be issued and the function will return undef. Other
wise, the function will return the XML as a string. The
XML structure will be similar to the following:
<cgi version="0.01" generator="CGI::toXML"><parameter name="dinosaur"><value>barney</value>
<value>godzilla</value></parameter>
<parameter name="color"><value>purple</value></parameter>- </cgi>
- as generated from the query string:
"dinosaur=barney&dinosaur=godzilla&color=purple"- The order of parameters and multivalued entries, as
returned by CGI, is maintained in the XML. - The options hash can be used to customize the behavior a
bit more: - include => [ list ]
- Only include the parameters and their values specified
in the given list; all other parameters are not
included. Note that this does not affect the CGI
object storage. - exclude => [ list ]
- Do not include the parameters and their values speci
fied in the given list; all other parameters are
included. Note that this does not affect the CGI
object storage.
EXPORT
No functions are exported by default, but CGItoXML can be
exported by the user.
AUTHOR
Michael K. Neylon, <mneylon-pm@masemware.com>
SEE ALSO
- perl, CGI::XML, XML::Simple.