Parse div using jsoup in java

Parse div using jsoup in java

Parse h2 tag inside div using Jsoup:

package in.javadomain;


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

public class DivParseJsoup {

	 * Main method to parse h2 tag inside div using jsoup
	 * @param args
	public static void main(String[] args) {
		Document doc;
		try {
			doc = Jsoup.connect("").get();
			// h2 is inside div so getting div first and h2 next.
			Elements h2Tag = doc.tagName("div#header-logo").getElementsByTag(
			System.out.println("Parsing h2 Tag using Jsoup => " + h2Tag.text());
		} catch (IOException e) {
		 System.out.println("Exception in Jsoup  " + e.getMessage());
			// e.printStackTrace();


[plain gutter=”false”]Parsing h2 Tag using Jsoup => Proud to be a programmer[/plain]

1,768 total views, 2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.