How to get XML data into a .gif

Posted by Peter Baaijens on 08-Mar-2011 08:37

Hi all,

I have a xml which contains somewhere an attribute "rawImage".

And I want to write the value of this attribute into a .gif file.

Tried several algorithms but not any luck so far.

The XML is included.

The value of rawImage is more than 32K, so GET-ATTRIBUTE won't work.

I even tried to write the whole xml to a longchar.

Than strip anything except for the rawImage value.

Put this longchar into a memptr and write this memptr to a file.

No errors, but windows won't recognize this as a valid .gif file .

        hDocument:SAVE("LONGCHAR",lcImage).

        ii = INDEX(lcImage,"rawImage=").

        lcImage = SUBSTRING(lcImage,ii + 10).

        ii = INDEX(lcImage,"/><ns17:wrappedObjects/>").

        lcImage = SUBSTRING(lcImage,1,ii - 2).

        SET-SIZE(memptrImage) = LENGTH(lcImage) + 1.

        PUT-STRING(memptrImage,1, LENGTH(lcImage) - 1) = lcImage.

        OUTPUT TO value(cImageName) BINARY NO-MAP NO-CONVERT.

        EXPORT memptrImage.

        OUTPUT CLOSE.

        SET-SIZE(memptrImage) = 0.

Any help would be appreciated

Peter @holland

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/23/result_2D00_xmap.xml:550:0]

All Replies

Posted by Admin on 08-Mar-2011 08:49

I even tried to write the whole xml to a longchar.

Than strip anything except for the rawImage value.

Put this longchar into a memptr and write this memptr to a file.

No errors, but windows won't recognize this as a valid .gif file .

 

That's not surprising.

In the XML document, that binary data will be encoded (probably base64). Using this method you'll write the still base64 encoded data to the .gif file.

Try to use the BASE64-DECODE function before writing the image to a file.

You didn't mention your version, on 10.2B GUI clients (prowin32, prowc) you could also use .NET XML classes that won't have the 32k limitation.

Posted by Peter Baaijens on 08-Mar-2011 09:10

You made my day!

This thread is closed