How to parse XML with jsoup

前端 未结 1 1717
星月不相逢
星月不相逢 2020-11-28 07:44

I am trying to parse XML with jsoup, but I can\'t find any examples on this task.

My XML document looks like this:



        
相关标签:
1条回答
  • 2020-11-28 08:13

    It seems the latest version of Jsoup (1.6.2 - released March 28, 2012) includes some basic support for XML.

    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);
    }
    

    Give that a shot..

    0 讨论(0)
提交回复
热议问题