Returns the root of an XML hierarchy, relative to a given child
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
getRoot(someChild);
}
public function getRoot (childNode:XML):XML {
var parentNode:XML = childNode.parent( );
if (parentNode != null) {
return getRoot(parentNode);
} else {
return childNode;
}
}
}
}
Related examples in the same category