Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to parse XML with jsoup
- <?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"));
- }
- 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>";
- Document doc = Jsoup.parse(html, "", Parser.xmlParser());
- for (Element e : doc.select("test")) {
- System.out.println(e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement