demojsoup5.java
package Jsoup;
import cn.wanghaomiao.xpath.model.JXDocument;
import cn.wanghaomiao.xpath.model.JXNode;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.File;
import java.util.List;
public class demojsoup5 {
public static void main(String[] args) throws Exception{
String path= demojsoup5.class.getClassLoader().getResource(“student.xml”).getPath();
Document document = Jsoup.parse(new File(path), “UTF-8”);
JXDocument jxDocument = new JXDocument(document);
List jxNodes = jxDocument.selN("//student");
for (JXNode jxNode : jxNodes) {
System.out.println(jxNode);
}
System.out.println("-----------------------");
List<JXNode> jxNodes1 = jxDocument.selN("//student/name[@id]");
for (JXNode jxNode : jxNodes1) {
System.out.println(jxNode);
}
System.out.println("-----------------------");
List<JXNode> jxNodes2 = jxDocument.selN("//student/name[@id='qige']");
for (JXNode jxNode : jxNodes2) {
System.out.println(jxNode);
}
}
}