E4X (XML used in ActionScript 3) has new operators to access values in XML. One operator is the @ operator which accesses attributes. It can be used in place of the attribute() (Top level XML.attribute()) method for obtaining attribute values. Ex:
var myXML:XML = <user name="senocular" id="2867" />;
trace(myXML.attribute("name")); // senocular
trace(myXML.attribute("id")); // 2867
trace(myXML.@name); // senocular
trace(myXML.@id); // 2867
You can also use an asterisk (*) with the @ operator to get a list of all attributes associated with an XML node in the form of an XMLList object. This is equivalent to the attributes() (Top level XML.attributes()) method. Ex:
var myXML:XML = <user name="senocular" id="2867" />;
var atts:XMLList;
atts = myXML.attributes();
trace(atts.toXMLString());
/* Output:
senocular
2867
*/
atts = myXML.@*;
trace(atts.toXMLString());
/* Output:
senocular
2867
*/
原文:http://www.kirupa.com/forum/showthread.php?s=923b583d23915c7b446c1ecf09d5fa2b&p=1914704#post1914704
另外,这个网上还一个长长的列表介绍AS3的功能,很是详细,可以去看看,上面是其中的一篇。
网址:http://www.kirupa.com/forum/showthread.php?t=223798
var myXML:XML = <user name="senocular" id="2867" />;
trace(myXML.attribute("name")); // senocular
trace(myXML.attribute("id")); // 2867
trace(myXML.@name); // senocular
trace(myXML.@id); // 2867
You can also use an asterisk (*) with the @ operator to get a list of all attributes associated with an XML node in the form of an XMLList object. This is equivalent to the attributes() (Top level XML.attributes()) method. Ex:
var myXML:XML = <user name="senocular" id="2867" />;
var atts:XMLList;
atts = myXML.attributes();
trace(atts.toXMLString());
/* Output:
senocular
2867
*/
atts = myXML.@*;
trace(atts.toXMLString());
/* Output:
senocular
2867
*/
原文:http://www.kirupa.com/forum/showthread.php?s=923b583d23915c7b446c1ecf09d5fa2b&p=1914704#post1914704
另外,这个网上还一个长长的列表介绍AS3的功能,很是详细,可以去看看,上面是其中的一篇。
网址:http://www.kirupa.com/forum/showthread.php?t=223798