W3C home > Mailing lists > Public > www-lib@w3.org > October to December 2000

Re: How to send a xml file to a server?

From: Jeff Adams <jeffa@coursewave.com>
Date: Mon, 11 Dec 2000 14:12:15 -0600
Message-ID: <3A35351F.F05777CA@coursewave.com>
To: www-lib@w3.org
Ailleen Lien wrote:
> 
> Anybody out there with sample code for sending a xml file to a server?

Depending upon how you want it stored or processed on the server,
one example is to simply use the POST method like the libwww example:

http://www.w3.org/Library/Examples/post.c

and send the XML from an in memory char * (converting to UTF-8 encoding
or
whatever encoding you are using).
The URL on the server could be, for instance, a servlet handling
doPost()
reuqests and it could process this text/xml instance...

some useful additions to the post.c sample code would
be setting up the correct MIME type by adding things like:

HTAnchor_setFormat(src, HTAtom_for("text/xml"));
HTAnchor_setCharset(src, HTAtom_for("UTF-8"));

If your app wanted to build up the char * data in steps you could
consider using an instance of a libwww HTChunk to do this and then
grab the resulting total char * with HTChunk_data(...) when you are
ready to POST

Jeff Adams
Received on Monday, 11 December 2000 15:11:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:38 GMT