Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you embed binary data in XML?

I have two applications written in Java that communicate with each other using XML messages over the network. I'm using a SAX parser at the receiving end to get the data back out of the messages. One of the requirements is to embed binary data in an XML message, but SAX doesn't like this. Does anyone know how to do this?

UPDATE: I got this working with the Base64 class from the apache commons codec library, in case anyone else is trying something similar.

like image 790
Bill the Lizard Avatar asked Aug 21 '08 13:08

Bill the Lizard


People also ask

How do we store binary data in XML?

There are two methods of encoding binary data in an XML document. The base64Binary encoding makes better use of the available XML characters, and on average a base64-encoded binary field is 2/3 the size of its hexBinary equivalent. Base64Binary is widely used by the MIME format and by various XML-based standards.

Does XML support binary?

Binary XML is typically used in applications where the performance of standard XML is insufficient, but the ability to convert the document to and from a form (XML) which is easily viewed and edited is valued. Other advantages may include enabling random access and indexing of XML documents.

What is binary XML language?

Binary XML format is an external representation of an XML value, which can be used for exchange of XML data between a client and a data server. The binary representation provides efficient XML parsing, which can result in performance improvements for XML data exchange.

Can XML be used for transmitting data?

XML is now widely used in business networks to integrate applications and transport data.


1 Answers

You could encode the binary data using base64 and put it into a Base64 element; the below article is a pretty good one on the subject.

Handling Binary Data in XML Documents

like image 167
Greg Hurlman Avatar answered Sep 28 '22 04:09

Greg Hurlman