Java XML Node Compare isDescendant(Node testNode, Node compareToNode)

Here you can find the source of isDescendant(Node testNode, Node compareToNode)

Description

is Descendant

License

Open Source License

Declaration

public static boolean isDescendant(Node testNode, Node compareToNode) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {

    public static boolean isDescendant(Node testNode, Node compareToNode) {
        if (testNode != null && compareToNode != null) {
            while (testNode.getParentNode() != null) {
                if (testNode.getParentNode() == compareToNode) {
                    return true;
                }/*w  w w. ja  v  a  2  s.c o  m*/
                testNode = testNode.getParentNode();
            }
        }
        return false;
    }
}

Related

  1. compareNodes(Node expected, Node actual)
  2. compareStringNode(Node node, String tag)
  3. compareTwoNodes(Node m, Node n)
  4. equalNode(Node nodeA, Node nodeB)
  5. equals(Node n1, Node n2)
  6. isNodeInNS(Node nodeToCompare, String nsuri, String tagName)
  7. isNodeSame(org.w3c.dom.Node node1, org.w3c.dom.Node node2)