Java HTML Jsoup Document getTextFromAvailableDivID(Document doc, String divID)

Here you can find the source of getTextFromAvailableDivID(Document doc, String divID)

Description

get Text From Available Div ID

License

Open Source License

Declaration

public static String getTextFromAvailableDivID(Document doc, String divID) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import org.jsoup.select.Elements;

public class Main {
    public static String getTextFromAvailableDivID(Document doc, String divID) {
        Elements elementsById = doc.getElementsByClass(divID);
        if (elementsById.size() > 0) {
            Element element = elementsById.first();
            String result = element.text();
            return result;
        } else {//from ww w  .j a  v a  2  s  .c  o m
            return "none";
        }
    }
}

Related

  1. getIcon(Document doc)
  2. getInfoboxLines(final Document html, final boolean stripColor)
  3. getJSoupHtmlDocument(final String url)
  4. getJSoupXmlDocument(final String url)
  5. getLoginFields(Document doc)
  6. getTitleFromDocument(Document doc)
  7. keepLineBreak(Document docRes)
  8. makeAbsolute(Document doc)
  9. normalizeWhitespaces(Document doc)