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(); }
반응형
'JAVA' 카테고리의 다른 글
apache configuration을 이용한 XML파일 작업 (0) | 2015.05.15 |
---|---|
URLConnection 을 이용해서 url결과를 가지고 오는 메소드 (0) | 2015.04.14 |
java메일 제목 깨지는 현상 (0) | 2015.03.30 |
replaceAll 사용시 특수문자 (0) | 2015.03.24 |
Pattern.matches (0) | 2015.03.24 |