tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jsoup > Wrap Element

Wrap Element 

Jsoup is an open source java library for parsing and manipulating HTML with ease. Get the latest binaries from This requires the library jsoup-1.6.1.jar to be in classpath. The following example shows wrapping a tag element over another element.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.jsoup.tests;

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

public class WrapHtmlTest {

   @param args
  public static void main(String[] args) {

    String html = "<html><body><b>BE THE CODER</b></body></html>";
    Document doc = Jsoup.parse(html);
    System.out.println(doc.body().children().first())//<b>BE THE CODER</b>
    doc.body().children().first().wrap("<span class='show'></span>");


It gives the following output,
File Name  :  OUTPUT


bl  br