libxml and binary data
BlitzMax Forums/BlitzMax Programming/libxml and binary data
| ||
Hi, just a quick question to all libxml users: what's the best way to store binary data in a node's content? Is there any buildin-functionality for it? Thanks Jake |
| ||
One way around it is to base64 encode the binary data, and then decode it on loading. Makes the data a bit bigger, but you might get away with compressing the xml too, if size is an issue (libxml supports de/compression of the document). |
| ||
Thanks, I'll give it a try. |
| ||
Ask yourself if you *really* need to do binary data in your xml file. Can you link to the binary data as a file and have an xml tag/attribute point to it? If it's because you want a "wad file" like solution, then look into zipping the xml together with the binary files. As a last resort look into XML CDATA |
| ||
I'd like to use a single file for exchanging parameters. All of them but a single image file are usual xml-tags. So I thought zipping them would be too much overhead and trouble for a single image that most of the time would be of small size. If I Base64 encode my image, do I need to use CData or can I store it the usual way as a contentstring? |
| ||
I think you'll be fine with just base64. There is a base64 writer in libxml, but I don't know if it's avalable in Bruceys module. http://xmlsoft.org/html/libxml-xmlwriter.html#xmlTextWriterWriteBase64 |
| ||
There is a base64 writer in libxml, but I don't know if it's avalable in Bruceys module. Cool... I never noticed that there. I guess that would be rather useful ;-) |
| ||
I've knocked together a small Base64 module which might be handy for this job. Info here : http://code.google.com/p/maxmods/wiki/Base64Module And available in the Downloads section. |
| ||
EXCELLENT! Just right in time. Thank you very very much! |