Java XML Node Parent isAncestorOf(Node ancestor, Node node)

Here you can find the source of isAncestorOf(Node ancestor, Node node)

Description

is Ancestor Of

License

Open Source License

Declaration

public static boolean isAncestorOf(Node ancestor, Node node) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static boolean isAncestorOf(Node ancestor, Node node) {
        while (node != null) {
            if (node == ancestor) {
                return true;
            }//from w ww  .  j a  v a 2 s. co m

            node = node.getParentNode();
        }

        return false;
    }
}

Related

  1. getParentNodeNoEx(Node node, String name)
  2. getParentOfNode(Node node)
  3. getParentOfNode(Node node)
  4. getParents(Node node)
  5. isAncestor(Node ancestor, Node node)
  6. isAncestorOf(Node candidateAncestor, Node candidateSibling, boolean strict)
  7. isAncestorOf(Node node, Node descendant)
  8. isAnyNodeAncestorOf(ArrayList ancestorNodes, Node node)
  9. isDescendant(Node test, Node target)