Hi how do i retrieve the top level parent of an xml node in actionscript please?
<companies>
<company id="1" name="boo" level="1">
<company id="2" name="hoo" level="2">
<company id="3" name="ooo" level="3"/>
</company>
</company>
</companies>
thanks in advance.
Edit (final):
I think I get what you are asking: what is the
company.(@level = 1)node that has the selectedcompany.(@level = 3)as a child. This is also known as an “ancestor” of the selected node. AS3 XML does not have a robust ancestor syntax, so you have to step upwards manually.For unknown levels of parenting, use a loop like the comments in this post discuss. Note that the following code uses the
idattribute for searching. This is because allids must be unique within a single XML, so you are guaranteed to find the id.