-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsoupDemo01.java
More file actions
30 lines (24 loc) · 792 Bytes
/
JsoupDemo01.java
File metadata and controls
30 lines (24 loc) · 792 Bytes
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
package xml;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
/**
* @author : CodeWater
* @create :2022-03-11-14:26
* @Function Description :
* Jsoup快速入门
*/
public class JsoupDemo01 {
public static void main(String[] args) throws IOException {
String path = JsoupDemo01.class.getClassLoader().getResource("xml/student.xml").getPath();
Document document = Jsoup.parse(new File(path), "utf-8");
Elements elements = document.getElementsByTag("name");
System.out.println(elements.size());
Element element = elements.get(0);
String name = element.text();
System.out.println(name);
}
}