Read CLOB from xml into Dataset / Temp-Table - Forum - OpenEdge Development - Progress Community

Read CLOB from xml into Dataset / Temp-Table

 Forum

Read CLOB from xml into Dataset / Temp-Table

This question is not answered

Hi everyone,

I'm trying to read some CLOB / LONGCHAR data from an XML file into a temp-table.

<?xml version="1.0" encoding="UTF-8"?>
<label>
    <labelID>1</labelID>
    <labelType>SHIPLABEL</labelType>
    <labelFormat>ZPL</labelFormat>
    <supplementaryLabel>false</supplementaryLabel>
    <labelContent type="base64">
        CgpeRlggU2hpcG1lbnQgSUQgICAgIDogJ
    </labelContent>
</label>

DEF TEMP-TABLE ttLabel NO-UNDO
    XML-NODE-NAME "label"
    FIELD labelID            AS INT     XML-NODE-TYPE "ATTRIBUTE"
    FIELD labelType          AS CHAR    XML-NODE-TYPE "ATTRIBUTE"
    FIELD labelFormat        AS CHAR    XML-NODE-TYPE "ATTRIBUTE"
    FIELD supplementaryLabel AS LOGICAL XML-NODE-TYPE "ATTRIBUTE"
    FIELD labelContent       AS CLOB    XML-NODE-TYPE "TEXT" XML-DATA-TYPE "base64Binary" COLUMN-CODEPAGE "UTF-8".

Now the file is read into the temp-table

TEMP-TABL ttMessage:READ-XML ("FILE", cMessage, "EMPTY", ?, ?, ?, "IGNORE").

The result for ttMessage.labelContent is a file named labelContent!UTF-8!1148_1.blb. This file only contains one return.

How can I read the contents of the base64 file from the XML using a TEMP-TABLE?

All Replies
  • Hi Johan,

    I have used this to get images from an XML and save them to files.

                        when "DigitalImageBinaryObject" then do:

                            /*

                            cMimeCode = hXImageLine:get-attribute ("mimeCode").

                            cFileName = hXImageLine:get-attribute ("fileName").

                            iEncoding = integer(hXImageLine:get-attribute ("encodingCode")).

                            */

                            hXImageLine:get-child (hXtext,1).

                            /*message hXtext:node-value view-as alert-box.*/

                            /* Save the string to a longchar to handle image larger than 32000 bytes */

                            hXtext:node-value-to-longchar ( decdlngc ).

                            /* Save the image bytes to a memptr */

                            decdmptr = base64-decode(decdlngc).

                            /* optionally create the image file */

                            copy-lob from decdmptr to file "C:\Development\Images\" + cProduct + "-" + cFileName + ".jpg".

                            iImages = iImages + 1.

                        end.    

    Hope the base64-decode can help you.

    Peter