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";
		 
		 HashMap hm = 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();
}


반응형
Posted by 질주하는구
,