Home > Actionscript 3.0, Flex > SimpleXMLEncoder and SimpleXMLDecoder

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 …. ;-)

About these ads
  1. zvi shalem
    September 22, 2010 at 1:11 am | #1

    thank you again!

  1. No trackbacks yet.

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: