本文整理汇总了Java中org.htmlcleaner.TagNode.removeFromTree方法的典型用法代码示例。如果您正苦于以下问题:Java TagNode.removeFromTree方法的具体用法?Java TagNode.removeFromTree怎么用?Java TagNode.removeFromTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.htmlcleaner.TagNode
的用法示例。
在下文中一共展示了TagNode.removeFromTree方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkScriptContent
import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
final private void checkScriptContent(TagNode node, Set<TagNode> disableScriptNodeSet) {
if (!("script".equalsIgnoreCase(node.getName())))
return;
if (disableScriptNodeSet != null && hasAncestorXPath(disableScriptNodeSet, node)) {
node.removeFromTree();
return;
}
StringBuilder builder = (StringBuilder) node.getText();
if (builder == null)
return;
String content = builder.toString();
if (content == null)
return;
String newContent = StringEscapeUtils.unescapeXml(content);
if (newContent.equals(content))
return;
node.removeAllChildren();
node.addChild(new ContentNode(newContent));
}
示例2: checkBaseHref
import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
final private void checkBaseHref(TagNode node) {
if (node == null)
return;
if (!"base".equalsIgnoreCase(node.getName()))
return;
String href = node.getAttributeByName("href");
if (href != null) {
try {
baseUrl = new URL(href);
} catch (MalformedURLException e) {
Logging.warn(e);
return;
}
}
node.removeFromTree();
}
示例3: removeMetaRefresh
import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
private void removeMetaRefresh(TagNode rootNode) {
for (TagNode element : rootNode.getElementListByName("meta", true)) {
String httpEquiv = element.getAttributeByName("http-equiv");
if (httpEquiv != null && httpEquiv.trim().equalsIgnoreCase("refresh")) {
element.removeFromTree();
}
}
}
示例4: removeUnqualifiedLinks
import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
/**
* Removes all <code>link</code> elements that can cause problems during
* RDFa extraction because they have an unqualified <code>rel</code>
* attribute, e.g.:
*
* <pre>
* <link rel="shortcut icon" href="favicon.ico" />
* </pre>
*/
public void removeUnqualifiedLinks() {
if (docNode == null) {
return;
}
final TagNode[] lLinks = docNode.getElementsByName("link", true); //$NON-NLS-1$
for (final TagNode lLink : lLinks) {
final String lRel = lLink.getAttributeByName("rel"); //$NON-NLS-1$
if (lRel.contains(" ")) { //$NON-NLS-1$
lLink.removeFromTree();
}
}
}