本文整理汇总了Java中net.htmlparser.jericho.Element.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getName方法的具体用法?Java Element.getName怎么用?Java Element.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.htmlparser.jericho.Element
的用法示例。
在下文中一共展示了Element.getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidTRTag
import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
private static boolean isValidTRTag(Tag tag) {
Element parentElement=tag.getElement().getParentElement();
if (parentElement==null) return false; // ignore TR elements without a parent
if (parentElement.getStartTag().getUserData()!=VALID_MARKER) return false; // ignore TR elements who's parent is not valid
if(parentElement.getName()==HTMLElementName.TABLE){
return true;
}
if(parentElement.getName()==HTMLElementName.TBODY
||parentElement.getName()==HTMLElementName.THEAD){
Element gradParent=parentElement.getParentElement();
if(gradParent==null){
return false;
}
if (gradParent.getStartTag().getUserData()!=VALID_MARKER) return false;
return (gradParent.getName()==HTMLElementName.TABLE);
}else{
return false;
}
}
示例2: isValidLITag
import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
private boolean isValidLITag(Tag tag) {
Element parentElement = tag.getElement().getParentElement();
if (parentElement == null)
return false; // ignore LI elements without a parent
if (parentElement.getStartTag().getUserData() != VALID_MARKER)
return false; // ignore LI elements who's parent is not valid
return parentElement.getName() == HTMLElementName.UL
|| parentElement.getName() == HTMLElementName.OL; // only accept
// LI tags
// who's
// immediate
// parent is
// UL or OL.
}
示例3: isValidLITag
import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
private boolean isValidLITag(Tag tag) {
Element parentElement = tag.getElement().getParentElement();
if (parentElement == null)
return false; // ignore LI elements without a parent
if (parentElement.getStartTag().getUserData() != VALID_MARKER)
return false; // ignore LI elements who's parent is not valid
// only accept LI tags who's immediate parent is UL or OL.
return parentElement.getName() == HTMLElementName.UL || parentElement.getName() == HTMLElementName.OL;
}
示例4: isValidLITag
import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
private static boolean isValidLITag(Tag tag) {
Element parentElement=tag.getElement().getParentElement();
if (parentElement==null) return false; // ignore LI elements without a parent
if (parentElement.getStartTag().getUserData()!=VALID_MARKER) return false; // ignore LI elements who's parent is not valid
return parentElement.getName()==HTMLElementName.UL || parentElement.getName()==HTMLElementName.OL; // only accept LI tags who's immediate parent is UL or OL.
}
示例5: isValidTDTHTag
import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
private static boolean isValidTDTHTag(Tag tag) {
Element parentElement=tag.getElement().getParentElement();
if (parentElement==null) return false; // ignore TD, TH elements without a parent
if (parentElement.getStartTag().getUserData()!=VALID_MARKER) return false; // ignore TD,TH elements who's parent is not valid
return parentElement.getName()==HTMLElementName.TR; // only accept TD,TH tags who's immediate parent is TR.
}
示例6: isValidTbodyTHeadTag
import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
private static boolean isValidTbodyTHeadTag(Tag tag) {
Element parentElement=tag.getElement().getParentElement();
if (parentElement==null) return false;
if (parentElement.getStartTag().getUserData()!=VALID_MARKER) return false;
return parentElement.getName()==HTMLElementName.TABLE;
}
示例7: removeNotAllowedTags
import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
/**
* Serduszko dla Bartka od Kasi <3
* @param htmlFragment
* @param docUri
* @return
*/
private String removeNotAllowedTags(String htmlFragment, URI docUri) {
Source source = new Source(htmlFragment);
OutputDocument outputDocument = new OutputDocument(source);
List<Element> elements = source.getAllElements();
for (Element element : elements) {
Attributes attrs = element.getAttributes();
Map<String, String> attrsUpdate = outputDocument.replace(attrs, true);
if (!element.getName().contains("a")) {
attrsUpdate.clear();
} else {
if (attrsUpdate.get("href")!=null) {
String link = attrsUpdate.get("href");
if (!link.contains("http")) {
URI documentUri = docUri;
URI anchorUri;
try {
anchorUri = new URI(link);
URI result = documentUri.resolve(anchorUri);
attrsUpdate.put("href", result.toString());
} catch (URISyntaxException e) {
outputDocument.remove(element);
}
}
}
}
if (NOT_ALLOWED_HTML_TAGS.contains(element.getName())) {
Segment content = element.getContent();
if (element.getName() == "script"
|| element.getName() == "style"
|| element.getName() == "form") {
outputDocument.remove(content);
}
outputDocument.remove(element.getStartTag());
if (!element.getStartTag().isSyntacticalEmptyElementTag()) {
outputDocument.remove(element.getEndTag());
}
}
}
String out = outputDocument.toString();
out = out.replaceAll("\\n", "");
out = out.replaceAll("\\t", "");
return out;
}