Code I/O

A topnotch site

5 Minutes on Adobe Flex: Marshalling AS3 Object to XML

Leave a comment

Here is a handy method that can quickly convert AS3 Object to XML.

		public static function objectToXML(object:Object, qualifiedName:String):XML
			var qName:QName = new QName(qualifiedName);
			var xmlDocument:XMLDocument = new XMLDocument();
			var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument);
			var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(object, qName, xmlDocument);

			return new XML(xmlDocument.toString());

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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