...

View Full Version : Base64 decoding and converting to xml



nitinmukesh
06-20-2012, 09:19 AM
Hi frnds,

I am working on a task where I have to convert the Flex application to HTML5.

I am stuck at the very first step where the Flex application is provided a Base64 encoded string and application converts it to xml. (The Base64 encoded string is XML)

Following is the code used in Flex

Base64.toXML(unescape("eNrtXMmS28gRvfsraniyDyXWvky0egKrRhGa8XissA8TEx1YCmpYJNEGQG0n/4b/wt/gT"));

This is the function in Flex used to convert Base64 encoded string to XML.



toXML(input:String, uncompress:Boolean = true):XML
{
var xml:XML;
var arr:ByteArray = Base64.decode(input);
if(uncompress) arr.uncompress();
arr.position = 0;
xml = new XML(arr.readUTFBytes(arr.length))
return xml;
}


I could find the base64Decode function in JQuery but how should I convert the decoded string to XML. I have been searching all over the net but could not find anything.

Any help is appreciated.

nitinmukesh
06-22-2012, 07:03 AM
I did some more research

It seems the xml is converted to ByteArray and then encoded to Base64. I can't change that because it has been developed and maintained by external developer.

In Flex
The received string is
1. unescaped
2. Base64 decoded
3. The received byte array is converted to XML.

Sample of code
http://codepad.org/6VteCm8F

I compared the Base64 decoded string in Flex and Javascript and there are few inconsistencies
http://codepad.org/ekrAdpgH

The very first problem is Base64 decoding is presenting slightly different results for Flex and Javascript

I also tried converting the ByteArray to string using the following code in javascript but it is not outputting anything
http://codepad.org/dKzzffKN

:( :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum