NAME
AnnoCPAN::XMLCGI - Read XML input through a CGI.pm-like interface
SYNOPSYS
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>
DESCRIPTION
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.
METHODS
- AnnoCPAN::XMLCGI->new
-
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.
- $cgi->param($name)
-
Return the value of the parameter $name. Note that, unlike CGI, it doesn't handle multiple values.
- $cgi->header
-
Returns a very simple header ("Content-type: text/html; charset=UTF-8\n\n").
SEE ALSO
AUTHOR
Ivan Tubert-Brohman <itub@cpan.org>
COPYRIGHT
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.