Sample code for 30+ languages & platforms
PureBasic

Decode HTML Entities found in XML

Demonstrates how to decode HTML entities found in XML.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkXml.pb"

Procedure ChilkatExample()

    success.i = 0

    ; Load an XML file containing the following:

    ; <?xml version="1.0" encoding="UTF-8"?>
    ; <output>Franz&#xf6;sische</output> 

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

    success = CkXml::ckLoadXmlFile(xml,"qa_data/xml/hasHtmlEntity.xml")

    ; Get non-decoded content, then get decoded content.

    ; Result is Franz&#xf6;sische
    Debug CkXml::ckContent(xml)

    ; Result is Französische
    strDecoded.s = CkXml::ckDecodeEntities(xml,CkXml::ckContent(xml))
    Debug strDecoded


    CkXml::ckDispose(xml)


    ProcedureReturn
EndProcedure