Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mime
string ls_Xml

li_Success = 0

//  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.

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
    destroy loo_Mime
    MessageBox("Error","Connecting to COM object failed")
    return
end if

ls_Xml = "<note><to>Bob</to><from>Alice</from><body>Hello</body></note>"
li_Success = loo_Mime.SetBodyFromXml(ls_Xml)
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    return
end if

Write-Debug "Content-Type: " + loo_Mime.ContentType


destroy loo_Mime