JAVA
RSS XML 정보를 가지고 오는 소스
질주하는구
2015. 4. 14. 14:36
SAXBuilder builder = new SAXBuilder(); try{ Document doc = builder.build("rss url 경로"); Element root = doc.getRootElement(); Element channelEle = root.getChild("channel"); List addressList = channelEle.getChildren("item"); Iterator it = addressList.iterator(); while (it.hasNext() == true){ Element emt = (Element)it.next(); String xmlIdx = "0"; String title = setReplaceNull(emt.getChild("title").getText()); String link = setReplaceNull(emt.getChild("link").getText()); String description = setReplaceNull(emt.getChild("description").getText()); String author = setReplaceNull(emt.getChild("author").getText()); String pubDate = setReplaceNull(emt.getChild("pubDate").getText()); String openChk = "Y"; HashMaphm = new HashMap (); hm.put("title", title); hm.put("link", link); hm.put("description", description); hm.put("author", author); hm.put("pubDate", pubDate); hm.put("openChk", openChk); hm.put("xmlIdx", xmlIdx); dataList.add(hm); } }catch(JDOMException e){ e.printStackTrace(); }
반응형