var xml:XML;
var name:string;
var elements:XMLList = xml..*[name]
What does ..*[]
do?
I have a xml that looks like:
<tag1 attr1="a">
<tag2 at开发者_如何学编程tr2="b">
</tag2>
</tag1>
why does xml..*["tag2"]
return null?
Not sure, I'm not used to access xml nodes through strings.
The ..
operator means desendants (similar to the children() method).
The *
is a wildcard, meaning all nodes on that level.
The []
would be array access notation, but since you've got E4X support
in as3, I don't see that often.
You can easily do this:
var xml:XML = <tag1 attr1="a">
<tag2 attr2="b" />
</tag1>;
var elements:XMLList = xml.tag2;
trace(elements.toXMLString());//prints: <tag2 attr2="b"/>
精彩评论