Solved

storing binary data in XML

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
c# code 19 73
C# SQL BULK INSERT CLASS 5 50
.net and XML report from SCCM 5 79
XML and version of MS XML Dom Document versions 5 43
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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