Created
January 13, 2011 08:29
-
-
Save weyert/777579 to your computer and use it in GitHub Desktop.
what's an easy way to prepare xml data for unit testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var types: Array = [ "slide" ]; | |
var myXML: XML = <schedules> | |
<schedule> | |
<item type="{types[0]}"><![CDATA[An example to be displayed.]]></item> | |
</schedule> | |
</schedules>; |
You don't need the " " round it. Amazingly (as flash is normally so annoying) it works out whether that is required and adds it for you.
so -
var testValues:Array = ['blah'];
var xml1:XML = <data>
<someVar>{testValues[0]}</someVar>
</data>;
// Gives
[trace] <data>
[trace] <someVar>blah</someVar>
[trace] </data>
And
var xml2:XML = <data>
<someVar label={testValues[0]}>1</someVar>
</data>
// Gives
[trace] <data>
[trace] <someVar label="blah">1</someVar>
[trace] </data>
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected result of trace( myXML.toXMLString() ) is that {types[0]} got replaced with slide