-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsoupDemo03.java
More file actions
38 lines (30 loc) · 1.13 KB
/
Copy pathJsoupDemo03.java
File metadata and controls
38 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package xml;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.jsoup.nodes.Element;
import java.io.IOException;
import java.io.File;
/**
* @author : CodeWater
* @create :2022-03-11-14:26
* @Function Description :
* Document/Element对象功能
*/
public class JsoupDemo03 {
public static void main(String[] args) throws IOException {
String path = JsoupDemo03.class.getClassLoader().getResource("xml/student.xml").getPath();
Document document = Jsoup.parse(new File(path), "utf-8");
Elements elements = document.getElementsByTag("student");
System.out.println(elements);
System.out.println("----------------");
Elements elements1 = document.getElementsByAttribute("id");
System.out.println(elements1);
System.out.println("---------------");
Elements elements2 = document.getElementsByAttributeValue("number", "heima_0001");
System.out.println(elements2);
System.out.println("-----------");
Element itcast = document.getElementById("itcast");
System.out.println(itcast);
}
}