[Tutor] Best way to POST XML to CGI

Alan Gauld alan.gauld at btinternet.com
Thu Jun 7 18:30:11 CEST 2007


"Ertl, John C CIV 63134" <john.ertl at navy.mil> wrote 

> I have a Python program that makes images of data 
> and I want to be able to make these via a web interface.  

Fair enough.

> I want to keep it simple so I thought I would send 
> an XML file to a cgi program 

But thats not simple. CGI is not really designed to deal with XML, 
they are almost complementary technologies. CGI sends 
name/value pairs either in GET or POST format. XML encodes 
the values into a text file. Different things. XML tends to be used 
for RPC or B2B type applications, CGI is typically used for basic 
form submissions.

Sure you can do it, but I'm not sure there is much point!
I'd probably look to use CGI to capture the details then 
create the XML file at the server end. Its a lot more efficient 
in terms of network bandwidth too. XML is about the most 
inefficient network "protocol" ever invented.

> I have an HTML form that I use to collect input on what 
> kind of image.   I then take that form input and make it 
> into an XML string.  I then take that XML string and POST 
> it to a CGI script.

As I say, a pretty complex process compared to a simple 
CGI submit action.

> I bet Python has a simple way to receive a XML post 
> so I do not have to look for a specific form name?

Python offers many ways to deal with XML file transmissions, 
including XML/RPC and SOAP. But CGI is probably not the 
best approach for XML IMHO. It can be done in the same way 
as posting a normal text file but its pretty much turning an 
easy job into a hard one for no benefit.

Alan G.



More information about the Tutor mailing list