Sample code for 30+ languages & platforms
PureBasic

Load MIME from XML

See more MIME Examples

Demonstrates the Chilkat Mime.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML. The only argument is the XML string.

Background: Chilkat can represent a MIME tree as XML — headers as elements, parameters as attributes — which is convenient for inspecting or editing structure with XML tools. This is the inverse of GetXml: it rebuilds the full MIME object from that representation. Invalid XML leaves the current object unchanged.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkMime.pb"

Procedure ChilkatExample()

    success.i = 0

    ;  Demonstrates the Mime.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML.
    ;  The only argument is the XML string.

    mime.i = CkMime::ckCreate()
    If mime.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  Chilkat MIME XML (as produced by GetXml).
    xmlText.s = "<mime><contentType>text/plain</contentType><body>Hello.</body></mime>"

    success = CkMime::ckLoadXml(mime,xmlText)
    If success = 0
        Debug CkMime::ckLastErrorText(mime)
        CkMime::ckDispose(mime)
        ProcedureReturn
    EndIf

    Debug "Content-Type: " + CkMime::ckContentType(mime)


    CkMime::ckDispose(mime)


    ProcedureReturn
EndProcedure