PowerBuilder
PowerBuilder
Convert MIME to XML
See more MIME Examples
Demonstrates the Chilkat Mime.GetXml method, which converts the MIME tree to Chilkat's XML representation and returns it as a string. It takes no arguments. Header names become element names, structured header parameters become attributes, and duplicate headers become repeated elements.
Tip: Code to parse the returned XML can be generated at Chilkat Tools.
Background: Turning a MIME tree into XML exposes its structure in a form that ordinary XML tools can query and transform — useful for inspection, debugging, or feeding a message into an XML-based pipeline. It is the inverse of
LoadXml, so a message can be round-tripped through XML. For a quick human-readable outline rather than a full representation, see GetStructure.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
string ls_Xml
li_Success = 0
// Demonstrates the Mime.GetXml method, which converts the MIME tree to Chilkat's XML
// representation and returns it as a string. It takes no arguments.
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
li_Success = loo_Mime.LoadMimeFile("qa_data/message.eml")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// Header names become XML element names and structured header parameters become XML attributes.
ls_Xml = loo_Mime.GetXml()
if loo_Mime.LastMethodSuccess = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
Write-Debug ls_Xml
destroy loo_Mime