我正在尝试使用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>
这个应该很简单,但是我的尝试失败了。
代码:
Element content = doc.getElementById("content");
Elements tests = content.getElementsByTag("tests");
for (Element testElement : tests) {
System.out.println(testElement.getElementsByTag("test"));
}