The first example shows how to use the The next example returns all attribute names:
The next example returns an attribute with a name that matches a
reserved word in ActionScript. You cannot use the syntax
@ (at sign) operator to
identify an attribute of an element:
var myXML:XML =
<item id = "42">
<catalogName>Presta tube</catalogName>
<price>3.99</price>
</item>;
trace(myXML.@id); // 42
var xml:XML =<example id='123' color='blue'/>
var xml2:XMLList = xml.@*;
trace(xml2 is XMLList); // true
trace(xml2.length()); // 2
for (var i:int = 0; i < xml2.length(); i++)
{
trace(typeof(xml2[i])); // xml
trace(xml2[i].nodeKind()); // attribute
trace(xml2[i].name()); // id and color
}
xml.@class
(since class is a reserved word in ActionScript). You need to use
the syntax xml.attribute("class"):
var xml:XML = <example class='123'/>
trace(xml.attribute("class")); // 123
----------------------------------------------------------------------------
@ (at sign) 과 Dot Syntax 맘에 든다.
무작정 childNodes로 돌리고 대략 정의내려서 작업했던 시절은 가고~ 좀더 직접적인 접근방식의 XML로써 코드의 양을 상당 줄여주고 효율성을 높였다. E4X(ECMAScript for XML)의 파워~


::: 사람과 사람의 교감! 人터넷의 첫 시작! 댓글을 달아주세요! :::