/* gcc -O2 -I/usr/include/libxml2 -o x x.c -lxml2 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>

int
main(int argc, char *argv[])
{
        xmlDoc *doc;
        xmlNodePtr envelope = NULL, body, method = NULL, head = NULL, text;
        xmlNsPtr ns = NULL;
	xmlChar *buf;
	int len;

        doc = xmlNewDoc("1.0");
        doc->encoding = xmlCharStrdup("UTF-8");
        doc->charset = XML_CHAR_ENCODING_UTF8;
	envelope = xmlNewDocNode(doc, NULL, "Envelope", NULL);
	ns = xmlNewNs(envelope, "http://www.w3.org/2003/05/soap-envelope", "env");
	xmlSetNs(envelope, ns);
        xmlDocSetRootElement(doc, envelope);

        body = xmlNewChild(envelope, ns, "Body", NULL);
	text = xmlNewTextLen(argv[1], strlen(argv[1]));
	xmlAddChild(body, text);

	xmlDocDumpMemory(doc, &buf, &len);
	write(1, buf, len);
	return (0);
}
