PDA

View Full Version : Simple XML query using E4X syntax question


blu3
07-29-2007, 03:36 PM
Let's say i have the following input xml example:


<test>
<body>
<par title="Example">
<img region="main" source="somePath"/>
<audio id="test" source="somePath2"/>
<img id="first" begin="00:00" />
<img id="second" begin="00:10" />
<img id="third" begin="00:20" />
</par>
</body>
</test>
Which i loaded from .xml file as an XML object and i would like to trace "begin" attribute value of an "img" node whose "id=second" and that would be "00:10". How can i do that, i tried with the following E4X statement:

myXML.body.par.img.(@id == "second").@begin.toXMLString())
but i get the following error in Flex Builder:

Main Thread (Suspended: ReferenceError: Error #1065: Variable @id is not defined.)
so i must have been doing something wrong but i am not sure why, can someone please help me on this?

thanks in advanced

Scottae
07-29-2007, 05:50 PM
I got the same thing too. I am new to AS 3.0 so I am not sure. Try looking here (http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4#e4x).

blu3
07-29-2007, 06:39 PM
I solved it in the end by using the following statement:

myXML.body.par.img.(attribute("id") == "second").@begin.toString()
Maybe this will help someone else too.

cheers

Scottae
07-29-2007, 07:04 PM
Ah hah........cool. Thanks for posting back.

blu3
07-29-2007, 09:29 PM
No problem :)

cheers