Change value of attribute on an XML object in AS3

17,170

Attributes are accessible in AS3 using the @ prefix.

For example:

var myXML:XML = <test name="something"></test>;
trace(myXML.@name);
myXML.@name = "new";
trace(myXML.@name);

Output:

something
new
Share:
17,170
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    Is there a easy way to do this? Or do I have to parse the file and do some search/replacing on my own?

    The ideal would be something like:

    var myXML: XML = ???; // ... load xml data into the XML object
    
    myXML.someAttribute = newValue; 
    
  • zproxy
    zproxy over 13 years
    You can also use the following syntax to access attributes: myXML.attribute("id"), myXML["@id"], and myXML.@["id"]. livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/…