Skip to content

Instantly share code, notes, and snippets.

@weyert
Created January 13, 2011 08:29
Show Gist options
  • Save weyert/777579 to your computer and use it in GitHub Desktop.
Save weyert/777579 to your computer and use it in GitHub Desktop.
what's an easy way to prepare xml data for unit testing
var types: Array = [ "slide" ];
var myXML: XML = <schedules>
<schedule>
<item type="{types[0]}"><![CDATA[An example to be displayed.]]></item>
</schedule>
</schedules>;
@weyert
Copy link
Author

weyert commented Jan 13, 2011

Expected result of trace( myXML.toXMLString() ) is that {types[0]} got replaced with slide

@Stray
Copy link

Stray commented Jan 13, 2011

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>

@weyert
Copy link
Author

weyert commented Jan 13, 2011

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment