/** * For the specified tag node, defines it's html content. This causes cleaner to * reclean given html portion and insert it inside the node instead of previous content. * * @param node * @param content */ public void setInnerHtml(TagNode node, String content) { if (node != null) { String nodeName = node.getName(); StringBuilder html = new StringBuilder(); html.append("<").append(nodeName).append(" " + MARKER_ATTRIBUTE + "=''>").append(content).append("</").append(nodeName).append(">"); TagNode parent = node.getParent(); while (parent != null) { String parentName = parent.getName(); html.insert(0, "<" + parentName + ">"); html.append("</").append(parentName).append(">"); parent = parent.getParent(); } TagNode innerRootNode = clean(html.toString()); TagNode cleanedNode = innerRootNode.findElementHavingAttribute(MARKER_ATTRIBUTE, true); if (cleanedNode != null) { node.setChildren(cleanedNode.getAllChildren()); } } }
/** * For the specified tag node, defines it's html content. This causes cleaner to * reclean given html portion and insert it inside the node instead of previous content. * @param node * @param content */ public void setInnerHtml(TagNode node, String content) { if (node != null) { String nodeName = node.getName(); StringBuilder html = new StringBuilder(); html.append("<").append(nodeName).append(" " +MARKER_ATTRIBUTE +"=''>").append(content).append("</").append(nodeName).append(">"); TagNode parent = node.getParent(); while (parent != null) { String parentName = parent.getName(); html.insert(0, "<" + parentName + ">"); html.append("</").append(parentName).append(">"); parent = parent.getParent(); } TagNode innerRootNode = clean( html.toString() ); TagNode cleanedNode = innerRootNode.findElementHavingAttribute(MARKER_ATTRIBUTE, true); if (cleanedNode != null) { node.setChildren( cleanedNode.getAllChildren() ); } } } /**