/** * Remove this node from the tree. * * @return True if element is removed (if it is not root node). */ public boolean removeFromTree() { return parent != null ? parent.removeChild(this) : false; }
/** * Remove this node from the tree. * * @return True if element is removed (if it is not root node). */ public boolean removeFromTree() { return parent != null ? parent.removeChild(this) : false; }
@Override public boolean removeFromTree() { bodyNode.removeChild(getToken()); return true; }
@Override public boolean removeFromTree() { bodyNode.removeChild(getToken()); return true; }
/** * There's a known limitation (bug?) in HTML Cleaner where if there's a XML declaration specified it'll be copied as * the first element of the body. Thus remove it if it's there. See * https://sourceforge.net/forum/message.php?msg_id=4657800 and * https://sourceforge.net/tracker/index.php?func=detail&aid=2688635&group_id=183053&atid=903696 * * @param cleanedNode the cleaned node (ie after the HTML cleaning) */ private void fixCleanedNodeBug(TagNode cleanedNode) { TagNode body = cleanedNode.getElementsByName("body", false)[0]; if (body.getChildren().size() > 0) { Object firstBodyChild = body.getChildren().get(0); if (firstBodyChild != null && ContentToken.class.isAssignableFrom(firstBodyChild.getClass())) { ContentToken token = (ContentToken) firstBodyChild; if (token.getContent().startsWith("<?xml")) { body.removeChild(token); } } } } }
@Override public TagNode apply(final TagNode node) { final String nodeName = node.getName(); if (!elements.containsKey(nodeName) && nodeName != null) { // if element is not whitelisted, ignore it, unless the node name is null which indicates // an omitted HTML envelope return null; } if (nodeName != null) { filterAttributes(node); } for (final TagNode childNode : node.getChildTags()) { if (apply(childNode) == null) { node.removeChild(childNode); } } return node; }
TagNode parent = tagNode.getParent(); if (parent != null) { parent.removeChild(tagNode);
TagNode parent = tagNode.getParent(); if (parent != null) { parent.removeChild(tagNode);
anchorTag.getParent().removeChild(anchorTag); continue; } else {