简体   繁体   中英

action script 3 xml parsing

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 attr2="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"/> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM