本文整理了Java中org.jsoup.nodes.Element.equals()
方法的一些代码示例,展示了Element.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.equals()
方法的具体详情如下:
包路径:org.jsoup.nodes.Element
类名称:Element
方法名:equals
暂无
代码示例来源:origin: org.jsoup/jsoup
static Elements filterOut(Collection<Element> elements, Collection<Element> outs) {
Elements output = new Elements();
for (Element el : elements) {
boolean found = false;
for (Element out : outs) {
if (el.equals(out)) {
found = true;
break;
}
}
if (!found)
output.add(el);
}
return output;
}
代码示例来源:origin: org.jsoup/jsoup
private void normaliseStructure(String tag, Element htmlEl) {
Elements elements = this.getElementsByTag(tag);
Element master = elements.first(); // will always be available as created above if not existent
if (elements.size() > 1) { // dupes, move contents to master
List<Node> toMove = new ArrayList<>();
for (int i = 1; i < elements.size(); i++) {
Node dupe = elements.get(i);
toMove.addAll(dupe.ensureChildNodes());
dupe.remove();
}
for (Node dupe : toMove)
master.appendChild(dupe);
}
// ensure parented by <html>
if (!master.parent().equals(htmlEl)) {
htmlEl.appendChild(master); // includes remove()
}
}
代码示例来源:origin: com.vaadin/flow-server
private static void insertElements(Element element,
Consumer<Element> action) {
if (element instanceof Document) {
element.getAllElements().stream()
.filter(item -> !(item instanceof Document)
&& element.equals(item.parent()))
.forEach(action::accept);
} else {
action.accept(element);
}
}
代码示例来源:origin: de.ruedigermoeller/kontraktor-http
public void stripComments(Document doc) {
List<Node> comments = new ArrayList<>();
doc.getAllElements().forEach( elem -> {
if ( ! elem.tagName().equals("style") && ! elem.equals("script") ) {
elem.childNodes().forEach( child -> {
if ( child instanceof Comment) {
comments.add(child);
}
});
}
});
comments.forEach(node -> node.remove());
}
代码示例来源:origin: com.vaadin/flow-server
private JsonArray getPath(org.jsoup.nodes.Element element,
org.jsoup.nodes.Element templateRoot) {
List<Integer> path = new ArrayList<>();
org.jsoup.nodes.Element current = element;
while (!current.equals(templateRoot)) {
org.jsoup.nodes.Element parent = current.parent();
path.add(indexOf(parent, current));
current = parent;
}
JsonArray array = Json.createArray();
for (int i = 0; i < path.size(); i++) {
array.set(i, path.get(path.size() - i - 1));
}
return array;
}
代码示例来源:origin: mohaps/xtractor
protected void append(Element node, StringBuilder sb, String tagName) {
// is select more costly then getElementsByTag?
MAIN:
for (Element e : node.select(tagName)) {
Element tmpEl = e;
// check all elements until 'node'
while (tmpEl != null && !tmpEl.equals(node)) {
if (unlikely(tmpEl))
continue MAIN;
tmpEl = tmpEl.parent();
}
String text = node2Text(e);
if (text.isEmpty() || text.length() < minParagraphText || text.length() > SHelper.countLetters(text) * 2)
continue;
sb.append(text);
sb.append("\n\n");
}
}
代码示例来源:origin: com.vaadin/flow-server
/**
* Returns the index of the {@code child} in the collection of
* {@link org.jsoup.nodes.Element} children of the {@code parent} ignoring
* "style" elements.
* <p>
* "style" elements are handled differently depending on ES5/ES6. Also
* "style" tag can be moved on the top in the resulting client side DOM
* regardless of its initial position (e.g. Chrome does this).
*
* @param parent
* the parent of the {@code child}
* @param child
* the child element whose index is calculated
* @return the index of the {@code child} in the {@code parent}
*/
private static int indexOf(org.jsoup.nodes.Element parent,
org.jsoup.nodes.Element child) {
Elements children = parent.children();
int index = -1;
for (org.jsoup.nodes.Element nextChild : children) {
if (!"style".equals(nextChild.tagName())) {
index++;
}
if (nextChild.equals(child)) {
break;
}
}
return index;
}
代码示例来源:origin: rubenlagus/TelegramBotsExample
result.word = capitalizeFirstLetter(word);
Elements tags = element.getElementsByTag("abbr");
tags.removeIf(x -> !x.parent().equals(element));
for (Element tag : tags) {
result.tags.put(tag.text(), tag.attributes().get("title"));
definition.removeIf(x -> !x.parent().equals(element));
if (definition.isEmpty()) {
results.addAll(findResultsFromRedirect(element, word));
代码示例来源:origin: perfectsense/dari
if (item.equals(prop)) {
continue;
} else if (!item.equals(closestItemScope(prop))) {
continue;
代码示例来源:origin: io.committed.krill/krill
if (ul == null || (ul.nextElementSibling() != null && !ul.nextElementSibling().equals(c))) {
ul = new Element(Tag.valueOf(wrappingParentTag), "");
c.replaceWith(ul);
代码示例来源:origin: zhegexiaohuozi/JsoupXpath
/**
* 获取同名元素在同胞中的index
* @param e
* @return
*/
public static int getElIndexInSameTags(Element e,Scope scope){
Elements chs = e.parent().children();
int index = 1;
for (Element cur : chs) {
if (e.tagName().equals(cur.tagName()) && scope.context().contains(cur)) {
if (e.equals(cur)) {
break;
} else {
index += 1;
}
}
}
return index;
}
代码示例来源:origin: cn.wanghaomiao/JsoupXpath
/**
* 获取同名元素在同胞中的index
* @param e
* @return
*/
public static int getElIndexInSameTags(Element e,Scope scope){
Elements chs = e.parent().children();
int index = 1;
for (Element cur : chs) {
if (e.tagName().equals(cur.tagName()) && scope.context().contains(cur)) {
if (e.equals(cur)) {
break;
} else {
index += 1;
}
}
}
return index;
}
代码示例来源:origin: com.norconex.collectors/norconex-importer
Element matchedElement = elms.get(0);
Element parentElement = getBodyElement(soupDoc);
if (matchedElement.equals(parentElement)) {
return docs;
内容来源于网络,如有侵权,请联系作者删除!