开发者

action script 3 xml parsing

开发者 https://www.devze.com 2023-03-06 10:57 出处:网络
var xml:XML; var name:string; var elements:XMLList = xml..*[name] What does ..*[] do? I have a xml that looks like:
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"/> 
0

精彩评论

暂无评论...
验证码 换一张
取 消