Contents

조회 수 13217 댓글 0
Atachment
첨부 '1'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

지인 부탁으로 만들었던 초간단 샘플~

버리기 아까워서 소스코드랑 샘플 xml 올려놓음..

한국일보 RSS 긁어오는 JSP 소스코드 샘플..

<%@ page language="java"
    contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.net.URL" %>
<%@ page import="java.util.List" %>
<%@ page import="org.xml.sax.InputSource" %>
<%@ page import="org.jdom.Document" %>
<%@ page import="org.jdom.Element" %>
<%@ page import="org.jdom.input.SAXBuilder" %>

<%
	List list = null;

	try{
		SAXBuilder parser = new SAXBuilder();
		parser.setValidation(false);
		parser.setIgnoringElementContentWhitespace(true);
		//URL url = new URL("http://jsp.hooni.net/rss/sample.xml");
		URL url = new URL("http://rss.hankooki.com/news/hk00_list.xml");
		InputSource is = new InputSource(url.openStream());
		Document doc = parser.build(is);

		Element root = doc.getRootElement();
		Element channel = root.getChild("channel");
		list = channel.getChildren("item");
	}catch(Exception e){
		e.getStackTrace();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RSS 열라 파씽</title>
</head>

<body>

<ul>

<%
	if(list!=null){
		for(int i=0; i<list.size(); i++){
			Element el = (Element) list.get(i);
%>
	<li><a href='<%=el.getChildText("link")%>' target=_news>
        <%=el.getChildText("title")%></a></li>
<%
		}
	}else{
%>
	<li>잠시 후 다시 접속하여 주십시오.</li>
<%
	}
%>
</ul>

</body>

</html>


?

  1. iOS 에서 쓸만한 오프라인 구글지도 찾기

  2. [doc] 웜 프레임워크 검증환경 구축(작성중..)

  3. 여기저기서 모은 VoIP(인터넷전화) 자료들~

  4. 티스토리 테이블 html,css 구문

  5. [owasp] 10대 웹어플리케이션 보안 취약

  6. [ppt] 웜 과제 진행사항(프레임워크 검증환경 구축) 보고

  7. 라우팅 경로 결정 영향 요소 ㅋㅋ

  8. OGNL(Object Graph Navigation Language)

  9. 영어의 12 시제 (The twelve tenses of English)

  10. [ios] APNS 클라이언트 구현 (pdf)

  11. [c] 윈도우 API sin 함수 출력..

  12. [router] 설정과 기본 명령어들 모음

Board Pagination Prev 1 ... 17 18 19 20 21 22 23 24 25 26 ... 98 Next
/ 98