Contents

조회 수 13202 댓글 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. OPT와 CAS에 대한 자료.. (교수님 메일로 보내드린 자료..)

    Date2013.04.23 CategoryDevelop Byhooni Views13915
    Read More
  2. [ios] iOS In App Purchase #2 (코드 구현)

    Date2013.11.20 CategoryDevelop Byhooni Views13764
    Read More
  3. [jsp] Get방식, Post방식 전송 예제..

    Date2003.04.23 CategoryDevelop Byhooni Views13754
    Read More
  4. [iphone] 아이폰 어플 모음 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views13707
    Read More
  5. [ios] Hybrid 앱 스터디 발표 자료

    Date2013.09.06 CategoryDevelop Byhooni Views13701
    Read More
  6. [js] window.open() 속성 사용 방법

    Date2013.11.18 CategoryDevelop Byhooni Views13586
    Read More
  7. [js] 자바스크립트를 동적으로 로딩하기

    Date2013.04.23 CategoryDevelop Byhooni Views13561
    Read More
  8. [c++] mfc 간단한 파일 입출력 예제

    Date2013.04.23 CategoryDevelop Byhooni Views13519
    Read More
  9. [c] 기본 자료형(int)이 표현할 수 없는 큰 수(Big number)를 덧셈하는 코드.

    Date2013.04.23 CategoryDevelop Byhooni Views13444
    Read More
  10. [ios] 간단한 방법으로 OS버전 확인하기.

    Date2013.09.24 CategoryDevelop Byhooni Views13302
    Read More
  11. [c#] 파일(File) 쓰기 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views13287
    Read More
  12. [jsp] RSS(xml) 파싱해서 보여주기 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views13202
    Read More
Board Pagination Prev 1 ... 10 11 12 13 14 15 16 17 18 19 ... 71 Next
/ 71