Java Code Examples for org.jsoup.nodes.Element#ownText()
The following examples show how to use
org.jsoup.nodes.Element#ownText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultKeyResolver.java From vscrawler with Apache License 2.0 | 5 votes |
@Override public String resolveKey(Element element) { String text = element.ownText(); if (!ChineseUtil.matches("[\\u4e00-\\u9fa5]+", text)) { return ChineseUtil.converterToSpell(ChineseUtil.matchesChineseValue(text)); } else { return ChineseUtil.converterToSpell(text); } }
Example 2
Source File: HtmlParser.java From gecco with MIT License | 5 votes |
public String $text(Element element, boolean own) { if (element == null) { return null; } String text = ""; if (own) { text = element.ownText(); } else { text = element.text(); } // 替换掉空格信息 return StringUtils.replace(text, "\u00A0", ""); }
Example 3
Source File: Node.java From JsoupXpath with Apache License 2.0 | 5 votes |
/** * 函数具体逻辑 * * @param scope 上下文 * @return 计算好的节点 */ @Override public XValue call(Scope scope) { Elements context = new Elements(); for (Element el:scope.context()){ context.addAll(el.children()); String txt = el.ownText(); if (StringUtils.isNotBlank(txt)){ Element et = new Element(""); et.appendText(txt); context.add(et); } } return XValue.create(context); }
Example 4
Source File: TtsHelper.java From coolreader with MIT License | 4 votes |
private void parseText(Elements elements, int startId) { Log.d(TAG, "Start ID:" + startId); boolean isSkip = true; if (startId == 0) isSkip = false; for (int idx = 0; idx < elements.size(); idx++) { Element el = elements.get(idx); if (el.hasAttr("id") && isSkip) { try { int id = Integer.parseInt(el.attr("id")); if (id >= startId) isSkip = false; } catch (Exception ex) { Log.e(TAG, ex.getMessage()); } } if (isSkip) continue; if (el.parent().hasClass("editsection")) continue; if (isWhiteSpace(el.tagName())) { SpeakValue s = new SpeakValue(); s.Val = SILENCE; s.ID = null; queue.add(s); } SpeakValue val = new SpeakValue(); // check if have children element for formatting boolean hasFormattingChild = false; for (Element child : el.children()) { if (FORMATTING_ELEMENTS.contains(child.tagName().toLowerCase())) { hasFormattingChild = true; break; } } if (hasFormattingChild) { Log.d(TAG, "Got formatting text: " + el.html()); val.Val = el.text(); Log.d(TAG, "Use text: " + el.text()); removeAllChildren(el, elements); idx--; } else { val.Val = el.ownText(); } if (el.hasAttr("id")) val.ID = el.attr("id"); else val.ID = null; queue.add(val); } }
Example 5
Source File: Functions.java From CrawlerForReader with Apache License 2.0 | 2 votes |
/** * 获取元素自己的子文本 * * @param e * @return */ public String text(Element e) { return e.ownText(); }