Here you can find the source of addTag(Element e, String tagName)
private static Element addTag(Element e, String tagName)
//package com.java2s; //License from project: Open Source License import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; public class Main { private static Document.OutputSettings setting; private static Element addTag(String fullHtml, String tagName) { return parse(fullHtml).body().tagName(tagName); }//from w w w . j a va 2 s .c om private static Element addTag(Element e, String tagName) { return parse(e.toString()).body().tagName(tagName); } /** * convert html String to {@link Document} (A lot more easier to manage it) * * @param html * input html * @return Document (include html body and head Tag) * @see Document * @see Document#head() * @see Document#body() */ public static Document parse(String html) { Document document = Jsoup.parse(html); if (setting != null) return document.outputSettings(setting); return document; } }