package cn.itcast.xml.jsoup; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import java.io.File; import java.io.IOException; import java.net.URL; /** * Jsoup对象功能 */ public class JsoupDemo2 { public static void main(String[] args) throws IOException { String path = JsoupDemo2.class.getClassLoader().getResource("student1.xml").getPath(); /* 1. Jsoup:工具类,可以解析html或xml文档,返回Document * parse:解析html或xml文档,返回Document */ //1.1 parse(File in, String charsetName):解析xml或html文件的。 Document document = Jsoup.parse(new File(path), "UTF-8"); System.out.println(document);//打印xml的文件内容 //1.2 parse(String html):解析xml或html字符串 String xml = "\n" + "\n" + "
\n" + " \n" + "