SimpleXMLEncoder and SimpleXMLDecoder


You might have heard or may be used these classes somewhere in your application where you had to deal with XML data. This classes are simple and pretty useful when you have convert some objects to XML or vice versa.
SimpleXMLEncoder:
SimpleXMLEncoder class takes object and encodes them into XML . This public method encodeValue takes the following as argument:
obj:Object – the object to be encoded
qname:QName  – the qualified name of the child node
parentNode:XMLNode – XMLNode under which the encoded value is put

Now letz try it out

code

and the trace should generate output  XML:

xml

SimpleXMLDecoder:
The simpleXMLDecoder will the do the exact reverse of the encoder with some changes in implementation.
Here the method is decode which takes in instance of XMLDocument as the argument.Now how its done:
decode

and the trace commands will give the output in the console as :
output

So this was a simple implementation example of both the classes …. 😉

Advertisements

Published by

Sunil Nair

I am a Software Developer currently working on developing Rich Internet Applications using Adobe Flex/AIR. I have had diverse experience of developing application in software industry for the last 4 years.

2 thoughts on “SimpleXMLEncoder and SimpleXMLDecoder”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s