ActionScript-3
I have an XML string that represents an object of any type (matrix of strings and primitives). I need to get the object / matrix out of the string.
// I have:
var xml: String = "<?xml version="1.0" encoding="utf-16"?><ArrayOfArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ArrayOfAnyType> <anyType xsi:type="xsd:string">TEXT</anyType> ....... </anyType></ArrayOfAnyType></ArrayOfArrayOfAnyType>"
// I need:
var obj: Object = ???;
// or in the end:
var array: Array = ???;
- How do I deserialize a string to object ?
- How do I serialize any object to string ?
Update:
- I took a look at the
children()list ofnew XML(str);object and I couldtrace()the values. So I could go by hand and iterate the lists to get my matrix but can't flash do that by itself ?
Update 2:
- I'm not using Flex
- my matrix also contains
DateTimevalues, so type attribute must be used as accurate as possible. - In order to deserialize the strings that I get I did what I wrote in the 1st update.
- Because of namespaces I couldn't get hold of the type attribute that is very important for me.
- So I killed all namespace garbage to get something like this:
<anyType type="string">blah blah</anyType>- I manipulated attribute-strings to kill the
"xsi:"and"xsd:"garbage
- I manipulated attribute-strings to kill the
- then I just iterated and build up the matrix I wanted.
- the question in not resolved though, I wished there would be a better way of doing this.