Java HTML Jsoup Element addTag(Element e, String tagName)

Here you can find the source of addTag(Element e, String tagName)

Description

add Tag

License

Open Source License

Declaration

private static Element addTag(Element e, String tagName) 

Method Source Code


//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;
    }
}

Related

  1. addAllNodes(Element parent, List childNodes)
  2. addProperty(Map ret, Element element)
  3. addStyle(Element element, String styleToBeAdded)
  4. appendFragment(Element e, String fragment)
  5. appendText(Element element, StringBuffer stringBuffer)
  6. childrenByTag(final Element element, final String tag)
  7. collectItemRewards(final Element icontab, final BiConsumer collector)