import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class heTang {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String fragment = "<div id='div1'>"
+ "<p id='para1'>This is the first paragraph</p>"
+ "<p id='para2'>Second paragraph here!" + "</div>";
Document doc = Jsoup.parseBodyFragment(fragment);
System.out.println(doc.toString());
}
}
输出:
<html>
<head></head>
<body>
<div id="div1">
<p id="para1">This is the first paragraph</p>
<p id="para2">Second paragraph here!</p>
</div>
</body>
</html>
含库源代码(Eclipse工程):http://pan.baidu.com/share/link?shareid=1742364754&uk=3878681452