我试图用jsoup解析XML,但我找不到关于此任务的任何示例.
我的XML文档如下所示:
<?xml version="1.0" encoding="UTF-8">
<tests>
<test>
<id>xxx</id>
<status>xxx</status>
</test>
<test>
<id>xxx</id>
<status>xxx</status>
</test>
....
</tests>
</xml>
Run Code Online (Sandbox Code Playgroud)
它应该很简单,但我的尝试失败了.
码:
Element content = doc.getElementById("content");
Elements tests = content.getElementsByTag("tests");
for (Element testElement : tests) {
System.out.println(testElement.getElementsByTag("test"));
}
Run Code Online (Sandbox Code Playgroud)