if (childNode instanceof Element) {
Element childElement = (Element) childNode;
if (elementName.equals(childElement.getName())) {
// Check to see if all the child attributes are
// present and the same in the parent.
Attribute attribute = childElement.getAttributes();
while (attribute != null && allChildrenRedundant) {
String value = element.getAttributeValue(
attribute.getName());
if (!attribute.getValue().equals(value)) {
// child's attributes are different
allChildrenRedundant = false;
}
attribute = attribute.getNext();
}
} else {
// element names are different
allChildrenRedundant = false;
}