Demo3.java
package cn.itcast
import org.dom4j.Document
import org.dom4j.DocumentException
import org.dom4j.Element
import org.dom4j.io.SAXReader
import java.io.File
import java.util.List
public class Demo3 {
public static void main(String[] args) throws DocumentException {
Document document = new SAXReader().read(new File("./personList.html"))
String xpath = "//tbody//tr"
List<Element> list =document.selectNodes(xpath)
for(Element element:list){
//获取到的是tr节点 然后获取子节点的文本 需要强转
System.out.print("编号:" + ((Element) element.elements().get(0)).getText())
System.out