Java tutorial
import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; public class Main { public static void parseHtml(String html) { Document document = Jsoup.parse(html); Element linkElement = document.select("a").first(); String linkHref = linkElement.attr("href"); // "http://sample.com" String linkText = linkElement.text(); // "This is sample" System.out.println(linkHref); System.out.println(linkText); } public static void main(String[] args) { String html = "<a onclick=\"xyz;\" target=\"_blank\" href=\"http://java2s.com\">This is sample</a>"; parseHtml(html); } }