protected boolean isEqual(Element element1, Element element2, XmlCompareMode mode) {

    if (!isEqualName(element1, element2)) {
      return false;
    }
    // compare attributes
    NamedNodeMap attributes1 = element1.getAttributes();
    NamedNodeMap attributes2 = element2.getAttributes();
    int length = attributes1.getLength();
    if (attributes2.getLength() != length) {
      return false;
    }
    for (int i = 0; i < length; i++) {
      Node attr1 = attributes1.item(i);
      String namespaceUri = attr1.getNamespaceURI();
      String name = getLocalName(attr1);
      Node attr2;
      if (namespaceUri == null) {
        attr2 = attributes2.getNamedItem(name);
      } else {
        attr2 = attributes2.getNamedItemNS(namespaceUri, name);
      }
      if (attr2 == null) {
        return false;
      }
      if (!attr1.getNodeValue().equals(attr2.getNodeValue())) {
        return false;
      }
    }
    if (!isEqual(element1.getChildNodes(), element2.getChildNodes(), mode)) {
      return false;
    }
    return true;
  }
protected boolean isEqual ( Element element1 , Element element2 , XmlCompareMode mode ) { if ( ! isEqualName ( element1 , element2 ) ) { return false ; } NamedNodeMap attributes1 = element1 . getAttributes ( ) ; NamedNodeMap attributes2 = element2 . getAttributes ( ) ; int length = attributes1 . getLength ( ) ; if ( attributes2 . getLength ( ) != length ) { return false ; } for ( int i = 0 ; i < length ; i ++ ) { Node attr1 = attributes1 . item ( i ) ; String namespaceUri = attr1 . getNamespaceURI ( ) ; String name = getLocalName ( attr1 ) ; Node attr2 ; if ( namespaceUri == null ) { attr2 = attributes2 . getNamedItem ( name ) ; } else { attr2 = attributes2 . getNamedItemNS ( namespaceUri , name ) ; } if ( attr2 == null ) { return false ; } if ( ! attr1 . getNodeValue ( ) . equals ( attr2 . getNodeValue ( ) ) ) { return false ; } } if ( ! isEqual ( element1 . getChildNodes ( ) , element2 . getChildNodes ( ) , mode ) ) { return false ; } return true ; }
This method determines if the given {@link Element elements} are equal.

@see #isEqual(Node, Node, XmlCompareMode)

@param element1 is the first {@link Element}.
@param element2 is the second {@link Element}.
@param mode is the mode of comparison.
@return {@code true} if equal, {@code false} otherwise.