I’m looking at the XML class.
I would like to be able to access elements by name and the order they came in.
For example, if an xml document is structured like this:
<a>
<b>info</b>
<d>something</d>
<b>more info</b>
</a>
I would like to get at it by doing somthing like:
xml_ojbect.findChild(“a”, 1).findChild(“b”, 2).nodeValue;
//returns the first element of type “a” and the second element of type “b” encountered.
From where I stand it doesn’t look like there is any way to traverse an XML document by giving a path using names.
For example, using Flash’s XML, I would have to do something like:
xml_object.childNodes[0].childNodes[2].nodeValue;
I have a problem if I can’t access nodes by the named type of the element.
For example, if the XML document is structured
<a>
<b>info</b>
//element <d> is not in this document
<b>more info</b>
</a>
the code: xml_object.childNodes[0].childNodes[2].nodeValue won’t work but xml_ojbect.findChild(“a”, 1).findChild(“b”, 2).nodeValue will work.
Another example:
xml_object.childNodes.length will return the number of childnodes there are. But I don’t see a way to get at the number of childnodes of a particular type. This will not tell me, for example, how many childnodes of type “b” that “a” has.
I can’t see Flash XML support being this sparse. Is there a built-in way of accessing the nth child of a node of a particular element name or am I stuck with accessing it only by number.