Unicode C
Unicode C
Set a MIME Body from XML
See more MIME Examples
Demonstrates the Chilkat Mime.SetBodyFromXml method, which sets the body as XML, changes the media type to text/xml, and selects an appropriate transfer encoding. The only argument is the XML text.
Background: This produces an XML-typed part, common in machine-to-machine messaging — SOAP, AS2/EDI payloads, structured data attachments. Marking the content
text/xml lets the receiver route and parse it correctly, and Chilkat picks a transfer encoding that preserves the XML across the transport.Chilkat Unicode C Downloads
#include <C_CkMimeW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMimeW mime;
const wchar_t *xml;
success = FALSE;
// Demonstrates the Mime.SetBodyFromXml method, which sets the body as XML and changes the media
// type to text/xml. The only argument is the XML text.
mime = CkMimeW_Create();
xml = L"<note><to>Bob</to><from>Alice</from><body>Hello</body></note>";
success = CkMimeW_SetBodyFromXml(mime,xml);
if (success == FALSE) {
wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
CkMimeW_Dispose(mime);
return;
}
wprintf(L"Content-Type: %s\n",CkMimeW_contentType(mime));
CkMimeW_Dispose(mime);
}