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


Flash / Flex / ActionScript examples » XML » XML hierarchy »

 

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;
      }
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo XML
» XML hierarchy