Java 使用jsoup从XML流中获取数据

Java 使用jsoup从XML流中获取数据,java,xml,jsoup,Java,Xml,Jsoup,我正试图从XML流中的这些标记之间获得“完成” <scan_run_status>Done</scan_run_status> 谢谢试试这个: Document doc = Jsoup.parse(input1); /* Grab all elements named "scan_run_sttus" */ Elements els = doc.select("scan_run_status"); /* If you need the first only ...her

我正试图从XML流中的这些标记之间获得“完成”

<scan_run_status>Done</scan_run_status>
谢谢

试试这个:

Document doc = Jsoup.parse(input1);
/* Grab all elements named "scan_run_sttus" */
Elements els = doc.select("scan_run_status");
/* If you need the first only ...here it is..*/
String status = els.first().text();
/* Otherwise you can loop 
for (Element el: els) {
   //.Do something
}
*/
别忘了检查els是否为空等等


您可以找到关于JSoup selector的所有提示。

就是这项工作-非常感谢
Document doc = Jsoup.parse(input1);
/* Grab all elements named "scan_run_sttus" */
Elements els = doc.select("scan_run_status");
/* If you need the first only ...here it is..*/
String status = els.first().text();
/* Otherwise you can loop 
for (Element el: els) {
   //.Do something
}
*/