Example #1
0
  /**
   * Returns true if both node-sets contain the same set of nodes.
   *
   * @param nl1 NodeList for first node-set
   * @param nl2 NodeList for second node-set
   * @return true if nl1 and nl2 contain exactly the same set of nodes.
   */
  public static boolean hasSameNodes(NodeList nl1, NodeList nl2) {

    NodeSet ns1 = new NodeSet(nl1);
    NodeSet ns2 = new NodeSet(nl2);

    if (ns1.getLength() != ns2.getLength()) return false;

    for (int i = 0; i < ns1.getLength(); i++) {
      Node n = ns1.elementAt(i);

      if (!ns2.contains(n)) return false;
    }

    return true;
  }