Solved

storing binary data in XML

Posted on 2002-07-19
7
790 Views
Last Modified: 2012-06-27
I'm curious about how I can store binary data in XML.
I know the CDATA functionality is often used to handle this, but, in my case, I can't be assured that the ]]> sequence will not be cointained in the data, causing all data after the ]]> character sequence to be lost. How can I get around this problem.
0
Comment
Question by:BeeRoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 1

Accepted Solution

by:
iamjhkang earned 25 total points
ID: 7166286
Base64 MIME encoding will do.

Visit the site below.
http://www.vbxml.com/xml/articles/binary/Default.asp

HTH.
0
 
LVL 3

Assisted Solution

by:monas
monas earned 25 total points
ID: 7167007
If your binary will have few ]]> sequences then you could split it into several CDATA elements on this text. for example "binary" "abcd]]>efgh" could be written:

<![CDATA[abcd]]]]><![CDATA[>efgh]]>

Yes, you have to go through all the binary when you put it into xml, and it have 12 bytes/sequence overhead but on most binaries this should give better result than guaranteed 30+% overhead of Base64.
0
 
LVL 3

Expert Comment

by:monas
ID: 7167011
Hmmm, what will happen if your binary will have sequences that are not present in UTF-8 - I don't know. Maybe someone could comment?
0
 
LVL 27

Expert Comment

by:BigRat
ID: 7169130
Strictly speaking inside a CDATA sequence the byte encoding should not matter. I prefer however the base64 encoding. In my RatScript I have implemented zlib to compress strings and base64 to encode them. Consequently storing binary data in XML is no problem - compress and base64 the result!
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question