开发者

(Flex 3) How do I get data from a xml file using HTTPservice and save the return data as an array?

开发者 https://www.devze.com 2022-12-08 19:12 出处:网络
I have an xml file (externally saved) that is similar to the following: [root]   [main]     [title]...[/title]

I have an xml file (externally saved) that is similar to the following:

[root]

  [main]

    [title]...[/title]

    [content]...[/content]

  [/main]

  [main]

    [title]...[/title]

    [content]...[/content]

  [/main]

[/root]

*All <> is replaced with [].

What I like to do is to get what's in [title] tag using HTTPservice, import it into Flex, and save it as ar开发者_如何学Goray objects, and do the same thing for [content]. This way I can later refer the array object saying title[0] or content[2].

I'm really new to Flex so your complete example is really appreciated.

LuckySamurai


flex using httpService with result event

<mx:HTTPService url="http://yours.com/caption.xml" resultFormat="e4x" id="xmlCaption" result="createCaptionArray(event)"/>

as3

        private function createCaptionArray(event:ResultEvent):void {
                            captionXML = new XML (event.result);

                            for each (var item:XML in captionXML.caption) {
                            // what ever u want to do here

                            }
        }
0

精彩评论

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