Answered
Attempting to learn XML all over again...
Okay, I’ve been at this for a good few hours now, but
no matter how much I read the help, it doesn’t seem to want
to work.
I have some xml that I’ve managed to read in and am able to properly trace:
<fruitBowl>
<fruit name=”apples” colour=”red” seeds=”yes” />
<fruit name=”pears” colour=”green” seeds=”yes” />
<fruit name=”grapes” colour=”purple” seeds=”sometimes” />
<fruit name=”blueberries” colour=”blue” seeds=”no” />
</fruitBowl>
Now, I want to be able to get the first fruit (and the next after, etc), and its attributes.
Logically, I think I should be able to do this by going (or something similar):
xmlListObject.child(0).attribute(“name”)
But actionscript 3 seems to disagree. When I trace the above (and tracing "xmlList.Object.child(0)" ), I get a blank (which appears to be because the tag actually has no value).
If I trace xmlListObject itself, I get my whole xml. If I trace xmlListObject.length(), it does return the right amount of children. But I can’t seem to isolate any 1 child and get an attribute from it.
Any ideas?
I have some xml that I’ve managed to read in and am able to properly trace:
<fruitBowl>
<fruit name=”apples” colour=”red” seeds=”yes” />
<fruit name=”pears” colour=”green” seeds=”yes” />
<fruit name=”grapes” colour=”purple” seeds=”sometimes” />
<fruit name=”blueberries” colour=”blue” seeds=”no” />
</fruitBowl>
Now, I want to be able to get the first fruit (and the next after, etc), and its attributes.
Logically, I think I should be able to do this by going (or something similar):
xmlListObject.child(0).attribute(“name”)
But actionscript 3 seems to disagree. When I trace the above (and tracing "xmlList.Object.child(0)" ), I get a blank (which appears to be because the tag actually has no value).
If I trace xmlListObject itself, I get my whole xml. If I trace xmlListObject.length(), it does return the right amount of children. But I can’t seem to isolate any 1 child and get an attribute from it.
Any ideas?