Advertisement
Guest User

Untitled

a guest
Apr 17th, 2012
1,673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. How to parse XML with jsoup
  2. <?xml version="1.0" encoding="UTF-8">
  3. <tests>
  4. <test>
  5. <id>xxx</id>
  6. <status>xxx</status>
  7. </test>
  8. <test>
  9. <id>xxx</id>
  10. <status>xxx</status>
  11. </test>
  12. ....
  13. </tests>
  14. </xml>
  15.  
  16. Element content = doc.getElementById("content");
  17. Elements tests = content.getElementsByTag("tests");
  18. for (Element testElement : tests) {
  19. System.out.println(testElement.getElementsByTag("test"));
  20. }
  21.  
  22. String html = "<?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>";
  23. Document doc = Jsoup.parse(html, "", Parser.xmlParser());
  24. for (Element e : doc.select("test")) {
  25. System.out.println(e);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement