aspose file tools*
The moose likes XML and Related Technologies and the fly likes Binary data via XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Binary data via XML" Watch "Binary data via XML" New topic
Author

Binary data via XML

Anu Host
Greenhorn

Joined: Apr 26, 2007
Posts: 7
Hi,

I was tying out to see if it is possible to send binary information(like an .jpeg file or .ppt file) embedded in an xml.
I was trying to have the file name and some more details in the xml and one of the tags in the xml would be the binary file itself. Is it possible to do this? The xml file so created will be moved from one location to another using SFTP. In the receiving location, I will have to store the file as it is - after extracting it(if required).

Any better suggestions on this are welcome.

Thanks,
Anoop
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Encode it with base64!
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Henry, your solution is 6 times less efficient than base64 in terms of space usage, you have 1 character/bit vs. 1 char/6bits, as with base64!
Anu Host
Greenhorn

Joined: Apr 26, 2007
Posts: 7
Thanks for the suggestion.
I was trying out some text which was encoded and decoded using base64 and it seems to work fine. Wanted to know if this is ok to be used for .jpeg files and if there are any chances for the image to be corrupted when decoding. I came to know that base64 uses only a-z, A-Z, 0-9, + and / but wanted to know if it is safe to use this in an xml.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18655
    
    8

Anu Host wrote:I was trying out some text which was encoded and decoded using base64 and it seems to work fine. Wanted to know if this is ok to be used for .jpeg files and if there are any chances for the image to be corrupted when decoding.

Base64 would be pretty useless if it didn't decode back to the original, wouldn't it?
I came to know that base64 uses only a-z, A-Z, 0-9, + and / but wanted to know if it is safe to use this in an xml.

XML would be pretty useless if it couldn't contain all of those characters, wouldn't it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Binary data via XML