开发者

AS3 select childeren in node

The current code is selecting all the items in <slideshow> using var itemsNode : XMLList = (xmlObject.children());

but i added an extra node to the xml called sunday around a couple of items. what should i change about var itemsNode : XMLList = (xmlObject.children()); to select all the items inside the node sunday, so i get the same result with var itemsNode : XMLList = (xmlObject.children()); and without the sunday node?

<slideshow width = "560" height = "373" 
        startWith = "1"
        backgroundColor = "0xB9A0BD" 
        backgroundTransparency = "0"
        randomSlideshow = "true"
        loop = "true">

    <sunday>
        <item>
            <path>content/images/image1.jpg</path>
            <target>开发者_运维问答_blank</target>

            <transitionTime>1</transitionTime>
            <slideShowTime>3</slideShowTime>
        </item>

        <item>
            <path>content/images/image2.jpg</path>
            <target>_blank</target>

            <transitionTime>1</transitionTime>
            <slideShowTime>3</slideShowTime>
        </item>
    </sunday>

</slideshow>


Try this:

var items:XMLList = xmlObject.sunday.item;


You can use the awesome E4X syntax to get all descendants (at any depth) of xmlObject named item:

var itemNodes : XMLList = xmlObject..item;

If you just want to skip one level (i.e. sunday) before selecting items, you can do:

var itemNodes : XMLList = xmlObject.*.item;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜