Solved

storing binary data in XML

Posted on 2002-07-19
7
788 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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