Java HTML Jsoup Element getElementTextBySelector(String html, String selector)

Here you can find the source of getElementTextBySelector(String html, String selector)

Description

get Element Text By Selector

License

Apache License

Declaration

public static String getElementTextBySelector(String html, String selector) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import org.jsoup.select.Elements;

public class Main {

    public static String getElementTextBySelector(String html, String selector) {
        Document document = Jsoup.parse(html);
        Elements e = document.select(selector);
        if (e == null || e.isEmpty()) {
            return null;
        }/*from w w w.ja  va2  s.c  om*/
        return Jsoup.parse(e.toString()).text();
    }
}

Related

  1. getDate(Elements caption)
  2. getDouble(Elements line, int idx)
  3. getElementByXPath(String xpath, Document doc)
  4. getElementsByClass(String className, Element boardElement)
  5. getElementsFirstLevel(String html)
  6. getElementValue(Element wrapperElement, String cssQuery)
  7. getElIndexInSameTags(Element e)
  8. getFirstWithOwnText(final Elements elementList, final String text)
  9. getFormattedText(Element element)