titleList = new ArrayList<>();
ListurlList = new ArrayList<>();
String url = MessageFormat.format("http://www.chinanews.com/rss/{0}.xml", type);
String httpContent = getHttpContent(url,"gbk");
Document doc = Jsoup.parse(httpContent, "", new Parser(new XmlTreeBuilder()));
//item
Elements itemElements = doc.select("item");
if(itemElements != null){
for(Element e : itemElements){
String title = e.select("title").first().text();
String link = e.select("link").first().text();
titleList.add(title);
urlList.add(link);
}
newsMap.put("title", titleList);
newsMap.put("url", urlList);
}
return newsMap;
}
```
### 二、运行效果
- 运行截图如下: