本文整理了Java中org.jsoup.nodes.Element.previousElementSibling()
方法的一些代码示例,展示了Element.previousElementSibling()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.previousElementSibling()
方法的具体详情如下:
包路径:org.jsoup.nodes.Element
类名称:Element
方法名:previousElementSibling
[英]Gets the previous element sibling of this element.
[中]获取此元素的上一个同级元素。
代码示例来源:origin: org.jsoup/jsoup
public boolean matches(Element root, Element element) {
if (root == element)
return false;
Element prev = element.previousElementSibling();
while (prev != null) {
if (evaluator.matches(root, prev))
return true;
prev = prev.previousElementSibling();
}
return false;
}
代码示例来源:origin: org.jsoup/jsoup
public boolean matches(Element root, Element element) {
if (root == element)
return false;
Element prev = element.previousElementSibling();
return prev != null && evaluator.matches(root, prev);
}
代码示例来源:origin: seven332/EhViewer
GalleryComment comment = new GalleryComment();
Element a = element.previousElementSibling();
String name = a.attr("name");
comment.id = Integer.parseInt(StringUtils.trim(name).substring(1));
代码示例来源:origin: org.jsoup/jsoup
private Elements siblings(String query, boolean next, boolean all) {
Elements els = new Elements();
Evaluator eval = query != null? QueryParser.parse(query) : null;
for (Element e : this) {
do {
Element sib = next ? e.nextElementSibling() : e.previousElementSibling();
if (sib == null) break;
if (eval == null)
els.add(sib);
else if (sib.is(eval))
els.add(sib);
e = sib;
} while (all);
}
return els;
}
代码示例来源:origin: astamuse/asta4d
public Element previousElementSibling() {
return originElement.previousElementSibling();
}
代码示例来源:origin: vsch/flexmark-java
final Element previousElementSibling = element.previousElementSibling();
final String tag = previousElementSibling == null ? null : previousElementSibling.tagName().toUpperCase();
if (tag != null && tag.equals(element.tagName().toUpperCase()) && (tag.equals("UL") || tag.equals("OL"))) {
代码示例来源:origin: code4craft/xsoup
public boolean matches(Element root, Element element) {
if (root == element)
return false;
Element prev = element.previousElementSibling();
while (prev != null) {
if (evaluator.matches(root, prev))
return true;
prev = prev.previousElementSibling();
}
return false;
}
代码示例来源:origin: stackoverflow.com
Elements fuel = doc.select("td.fuel_segmented");
for (Element element : fuel) {
System.out.println(element.previousElementSibling().text()
+ ": " + element.text());
}
代码示例来源:origin: stackoverflow.com
Element page = doc.select("li[class*=a-last]").first();
System.out.println("Value of List Item : " + page.previousElementSibling().text());
代码示例来源:origin: us.codecraft/xsoup
public boolean matches(Element root, Element element) {
if (root == element)
return false;
Element prev = element.previousElementSibling();
while (prev != null) {
if (evaluator.matches(root, prev))
return true;
prev = prev.previousElementSibling();
}
return false;
}
代码示例来源:origin: stackoverflow.com
Elements tables = document.select("div#page_content_list01>table");
for (Element table : tables){
Element h2 = table.previousElementSibling();
String titleStr = h2.text();
Element a = table.select("a").first();
String linkStr = a.attr("href");
}
代码示例来源:origin: stackoverflow.com
Elements brackets = doc.getElementsByTag("bracket");
for (Element bracket : brackets) {
Element lis = bracket.select("li");
Element name = bracket.previousElementSibling();
System.out.println(name.text());
for (Element li : lis){
System.out.println(li.text());
}
}
代码示例来源:origin: code4craft/xsoup
public boolean matches(Element root, Element element) {
if (root == element)
return false;
Element prev = element.previousElementSibling();
return prev != null && evaluator.matches(root, prev);
}
代码示例来源:origin: us.codecraft/xsoup
public boolean matches(Element root, Element element) {
if (root == element)
return false;
Element prev = element.previousElementSibling();
return prev != null && evaluator.matches(root, prev);
}
代码示例来源:origin: cn.wanghaomiao/JsoupXpath
public static Elements precedingSibling(Element el){
Elements rs = new Elements();
Element tmp = el.previousElementSibling();
while (tmp!=null){
rs.add(tmp);
tmp = tmp.previousElementSibling();
}
if (rs.size() > 0){
return rs;
}
return null;
}
}
代码示例来源:origin: stackoverflow.com
Document document = Jsoup.parse(html);
Elements elements = document.select("#tableMain tr:has(td.location) + tr");
for (Element element : elements) {
String location = element.previousElementSibling().select("td.location").text();
System.out.printf("Current location: '%s'%n", location);
Elements titleLists = element.select("#titleList > tbody > tr");
for (Element tr : titleLists) {
String title = tr.select("td.title").text();
String date = tr.select("td.date").text();
String time = tr.select("td.time").text();
System.out.printf("Title: %s, Date: %s, Time: %s%n", title, date, time);
}
}
代码示例来源:origin: zhegexiaohuozi/JsoupXpath
public static Elements precedingSibling(Element el){
Elements rs = new Elements();
Element tmp = el.previousElementSibling();
while (tmp!=null){
rs.add(tmp);
tmp = tmp.previousElementSibling();
}
if (rs.size() > 0){
return rs;
}
return null;
}
}
代码示例来源:origin: io.committed.krill/krill
private void convertSpiltBulletsToLists(final Document document) {
document.select("p ~ p").forEach(p -> {
final Element previous = p.previousElementSibling();
final String previousText = previous.text().trim();
if (LISTITEM_SYMBOLS.stream().anyMatch(s -> s.equals(previousText))) {
// So bullet then paragraph...
// Delete prvious and turn the other into a list item
previous.remove();
p.tagName("li");
}
});
}
代码示例来源:origin: zhegexiaohuozi/JsoupXpath
/**
* @param context
* @return res
*/
@Override
public XValue apply(Elements context) {
Set<Element> total = new HashSet<>();
for (Element el : context){
if (el.previousElementSibling()!=null){
total.add(el);
}
}
Elements newContext = new Elements();
newContext.addAll(total);
return XValue.create(newContext);
}
}
代码示例来源:origin: cn.wanghaomiao/JsoupXpath
/**
* @param context
* @return res
*/
@Override
public XValue apply(Elements context) {
List<Element> total = new LinkedList<>();
for (Element el : context){
if (el.previousElementSibling()!=null){
total.add(el);
}
}
Elements newContext = new Elements();
newContext.addAll(total);
return XValue.create(newContext);
}
}
内容来源于网络,如有侵权,请联系作者删除!