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