List of utility methods to do HTML Jsoup Element
String | getAuthorName(Element authorElement) get Author Name return authorElement.text().trim();
|
List | getCodeSnippetCLT(Element codeElement, String content, String fqn, String api, String kind, String[] titles) get Code Snippet CLT List<Integer> indexes = new ArrayList<Integer>(); if (codeElement.tagName().equals("pre")) { if (content.startsWith("M")) { content = content.split(":")[2]; } else if (content.startsWith("F")) { content = content.split(":")[3]; } else { String[] tmp = content.split(":")[1].split("\\."); ... |
Date | getDate(Elements caption) get Date String date = caption.text(); DateTimeFormatter dtf = DateTimeFormat.forPattern("dd/MM/yyyy"); return DateTime.parse(date, dtf).toDate(); |
Double | getDouble(Elements line, int idx) get Double return Double.valueOf(line.get(idx).text());
|
Element | getElementByXPath(String xpath, Document doc) get Element By X Path String[] tags = xpath.substring(11, xpath.length()).split("/"); Element clt = doc.body(); int index; int divc = 0; boolean done = false; for (String tag : tags) { if (tag.startsWith("div")) divc++; ... |
Elements | getElementsByClass(String className, Element boardElement) get Elements By Class Elements elements = boardElement.getElementsByClass(className); if (elements != null && !elements.isEmpty()) { return elements; return null; |
List | getElementsFirstLevel(String html) Return the first level of the elements given a element Body. Document docu = Jsoup.parse(html); List<Element> elements = new ArrayList<Element>(); for (Node node : docu.getAllElements()) { if (node instanceof Element && node.parentNode() != null && node.parentNode().equals(docu.body())) { elements.add((Element) node); return elements; ... |
String | getElementTextBySelector(String html, String selector) get Element Text By Selector Document document = Jsoup.parse(html); Elements e = document.select(selector); if (e == null || e.isEmpty()) { return null; return Jsoup.parse(e.toString()).text(); |
String | getElementValue(Element wrapperElement, String cssQuery) get Element Value try { Element elm = wrapperElement.select(cssQuery).first(); return elm.text(); } catch (Exception e) { e.printStackTrace(); return ""; |
int | getElIndexInSameTags(Element e) get El Index In Same Tags Elements chs = e.parent().children(); int index = 1; for (int i = 0; i < chs.size(); i++) { Element cur = chs.get(i); if (e.tagName().equals(cur.tagName())) { if (e.equals(cur)) { break; } else { ... |