Returns the root of an XML hierarchy, relative to a given child : XML hierarchy « XML « Flash / Flex / ActionScript






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

1.Find data nested deep within an XML tree.