Open sushihangover opened 9 years ago
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html
attributes () method
AS3 function attributes():XMLList
Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9
Returns a list of attribute values for the given XML object. Use the name() method with the attributes() method to return the name of an attribute. Use of xml.attributes() is equivalent to xml.@*.
Returns XMLList — The list of attribute values. More examples
Traversing XML structures Learn more
XML objects Related API Elements
XML.attribute() XML.name() @ operator
Example ( How to use this example )
The following example returns the name of the attribute:
var xml:XML=<example id='123' color='blue'/>
trace(xml.attributes()[1].name()); //color
This example returns the names of all the attributes:
var xml:XML = <example id='123' color='blue'/>
var attNamesList:XMLList = xml.@*;
trace (attNamesList is XMLList); // true
trace (attNamesList.length()); // 2
for (var i:int = 0; i < attNamesList.length(); i++)
{
trace (typeof (attNamesList[i])); // xml
trace (attNamesList[i].nodeKind()); // attribute
trace (attNamesList[i].name()); // id and color
}
// Compiler options: -psstrict-
package {
public class Foo {
public static function Main():int {
var xml:XML = <example id='123' color='blue'/>
var attNamesList:XMLList = xml.@*;
trace (attNamesList is XMLList); // true
trace (attNamesList.length()); // 2
for (var i:int = 0; i < attNamesList.length(); i++)
{
trace (typeof (attNamesList[i])); // xml
trace (attNamesList[i].nodeKind()); // attribute
trace (attNamesList[i].name()); // id and color
}
return 0;
}
}
}
Currently XML.attributes is not implemented
New Test: as/test-as-XML-Attrubutes-Access.as