Java HTML Jsoup Document detectLanguage(Document doc)

Here you can find the source of detectLanguage(Document doc)

Description

detect Language

License

Apache License

Declaration

public static String detectLanguage(Document doc) 

Method Source Code

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

import org.jsoup.nodes.*;

public class Main {
    public static String detectLanguage(Document doc) {
        Element htmlTag = doc.select("html").first();
        if (htmlTag.attributes().hasKey("lang")) {
            return htmlTag.attr("lang");
        }//  w w  w .  java 2s  . co m
        if (htmlTag.attributes().hasKey("xml:lang")) {
            return htmlTag.attr("xml:lang");
        }
        return null;
    }
}

Related

  1. applyCacheKeysToResourceUrls(Document document, long pluginModifiedTimestamp, Locale locale)
  2. convertLinksToAbsolute(String link, org.jsoup.nodes.Document doc)
  3. emptyDocument()
  4. formatDocument(Document doc)
  5. getAllText(Document document)
  6. getCategoryIds(final Document html)