import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class JsoupParserTest {
public static void main(String[] args) {
StringBuilder buf = new StringBuilder();
buf.append("<html>");
buf.append("<head>");
buf.append("<title>这是标题。</title>");
buf.append("</head>");
buf.append("<body>");
buf.append("<p>这是内容。</p>");
buf.append("</body>");
buf.append("</html>");
String html = buf.toString();
Document doc = Jsoup.parse(html);
System.out.println(doc);
}
}
输出如下:
<html>
<head>
<title>这是标题。</title>
</head>
<body>
<p>这是内容。</p>
</body>
</html>
要运行此程序,需要以下jar包:
jsoup-1.11.3.jar