*/
private boolean tableElementHasContent(Element tableElement) {
boolean hasContent = false;
if ("table".equals(tableElement.getName())) {
// Iterate through the rows to look for content.
Node child = tableElement.getHead();
while (child != null && !hasContent) {
if (child instanceof Element) {
hasContent = tableElementHasContent((Element) child);
}
if (!hasContent) {
child = child.getNext();
}
}
} else if ("tr".equals(tableElement.getName())) {
// Iterate through the cells to look for content.
Node child = tableElement.getHead();
while (child != null && !hasContent) {
if (child instanceof Element) {
hasContent = tableElementHasContent((Element) child);
}
if (!hasContent) {
child = child.getNext();
}
}
} else if ("td".equals(tableElement.getName()) ||
"th".equals(tableElement.getName())) {
// Iterate through the table children to look for content.
Node child = tableElement.getHead();
while (child != null && !hasContent) {
if (child instanceof Element) {
hasContent = true;
} else {
hasContent = ((Text) child).getLength() > 0;
}
child = child.getNext();
}
} else {
// Non table, tr, td and th elements are considered to have
// content.
hasContent = true;