本文整理汇总了Java中org.jsoup.nodes.Element.tagName方法的典型用法代码示例。如果您正苦于以下问题:Java Element.tagName方法的具体用法?Java Element.tagName怎么用?Java Element.tagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.nodes.Element
的用法示例。
在下文中一共展示了Element.tagName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeUselessElements
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private static void removeUselessElements(Element element) {
for (Element child : element.children()) {
if (child.children().size() > 0)
removeUselessElements(child);
else {
switch (child.tagName()) {
case "br":
case "a":
case "p":
case "h1":
case "h2":
case "h3":
case "h4":
case "span":
break;
default:
Element parent = child.parent();
child.remove();
parent.insertChildren(0, child.children());
break;
}
}
}
}
示例2: head
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public void head(Node source, int depth) {
if (skipChildren) {
return;
}
if (source instanceof Element) {
Element sourceElement = (Element) source;
if (isSafeTag(sourceElement)) {
String sourceTag = sourceElement.tagName();
Attributes destinationAttributes = sourceElement.attributes().clone();
Element destinationChild = new Element(Tag.valueOf(sourceTag), sourceElement.baseUri(), destinationAttributes);
destination.appendChild(destinationChild);
destination = destinationChild;
} else if (source != root) {
skipChildren = true;
}
} else if (source instanceof TextNode) {
TextNode sourceText = (TextNode) source;
TextNode destinationText = new TextNode(sourceText.getWholeText(), source.baseUri());
destination.appendChild(destinationText);
} else if (source instanceof DataNode && isSafeTag(source.parent())) {
DataNode sourceData = (DataNode) source;
DataNode destinationData = new DataNode(sourceData.getWholeData(), source.baseUri());
destination.appendChild(destinationData);
}
}
示例3: call
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public Object call(Element element, List<SyntaxNode> params) {
return element.tagName();
}
示例4: parseFormattedMessageNode
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private void parseFormattedMessageNode(org.jsoup.nodes.Node node, List<Element> p) {
List textFlowList = bodyContainer.getChildren();
List<Element> parents = p;
if(node instanceof TextNode) {
// Ignore TextNodes containing only whitespace
if(!node.outerHtml().replace(" ", "").equals("")) {
String text = ((TextNode) node).getWholeText();
Text textObject = new Text(text);
boolean pre = false;
// Go through all parent tags and apply styling
for(Element element : parents) {
String tagName = element.tagName();
if ("ul".equals(tagName)) { // Begin bullet list
} else if("ol".equals(tagName)) { // TODO: Begin numbered list
} else if("li".equals(tagName)) {
// List item
textFlowList.add(new Text(" • "));
} else if("blockquote".equals(tagName)) {
textObject.getStyleClass().add("block-quote");
} else if("pre".equals(tagName)) {
// Preceeds a <code> tag to specify a multiline block
pre = true;
} else if("code".equals(tagName)) {
// Monospace and TODO: code highlighting
if(pre) {
textObject.getStyleClass().add("block-monospace");
} else {
textObject.getStyleClass().add("inline-monospace");
}
break; // We don't care about anything appearing within a <code> tag
} else {
// Other tags are applied ass CSS classes
textObject.getStyleClass().add(tagName);
}
}
textFlowList.add(textObject);
textObject.applyCss();
}
} else if(node instanceof Element) {
parents = new LinkedList<>(parents);
parents.add((Element)node);
}
// Recursively parse child tags
for(org.jsoup.nodes.Node child: node.childNodes()) {
parseFormattedMessageNode(child, parents);
}
}