1
我试图让这个XML“链接”标签元素的文本:http://www.istana.gov.sg/latestupdate/rss.xmlJsoup。选择返回空值,但元素也包含文本
我已经编码得到的第一篇文章。
URL = getResources().getString(R.string.istana_home_page_rss_xml);
// URL = "http://www.istana.gov.sg/latestupdate/rss.xml";
try {
doc = Jsoup.connect(URL).ignoreContentType(true).get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// retrieve the link of the article
links = doc.select("link");
// retrieve the publish date of the article
dates = doc.select("pubDate");
//retrieve the title of the article
titles = doc.select("title");
String[] article1 = new String[3];
article1[0] = links.get(1).text();
article1[1] = titles.get(1).text();
article1[2] = dates.get(0).text();
该文章很好地发表,但链接返回“”值(整个链接元素返回“”值)。标题和日期没有任何问题。链接标签包含一个URL文本。任何人都知道为什么,它返回“”值?
工作就像一个魅力。谢谢你这么多Pshemo! – burper333