AnnoCPAN::XMLCGI - Read XML input through a CGI.pm-like interface
use AnnoCPAN::XMLCGI; my $cgi = AnnoCPAN::XMLCGI->new; my $name = $cgi->param('name'); print $cgi->header; print "Hello, $name!\n"; # Hello, Bob! # In STDIN... <data> <name>Bob</name> <age>123</age> <data>
This module reads XML from STDIN and makes it available through and interface that is compatible with a subset of that for CGI. Its purpose is to be used as a drop-in replacement for CGI for JavaScript XMLHttpRequest handlers that receive their input in XML instead of the typical CGI form encoding.
Note that only a very minimal subset of CGI is implemented, but it is the only part that is required for most simple uses.
The input stream is expected to be a very simple XML structure with only one level of depth, and with no duplicate keys. The root element (<data> in the example above) can be have any tag name.
Create an AnnoCPAN::XMLCGI object. Doesn't take any parameters. When called, it slurps everything in STDIN; therefore it's not a very good idea to call it more than once.
Returns false if there was a parsing error.
Return the value of the parameter $name. Note that, unlike CGI, it doesn't handle multiple values.
Returns a very simple header ("Content-type: text/html; charset=UTF-8\n\n").
CGI, XML::Simple
Ivan Tubert-Brohman <itub@cpan.org>
Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install AnnoCPAN, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnnoCPAN
CPAN shell
perl -MCPAN -e shell install AnnoCPAN
For more information on module installation, please visit the detailed CPAN module installation guide.