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. [jsp] RSS(xml) 파싱해서 보여주기 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views13217
    Read More
  2. [linux] 아파치설치/설정 - SSI(Server Side Include)

    Date2003.04.23 CategorySystem/OS Byhooni Views13207
    Read More
  3. [ios] App States

    Date2013.07.22 CategoryDevelop Byhooni Views13196
    Read More
  4. [js] xsl 강의 자료

    Date2013.04.23 CategoryPPT Byhooni Views13188
    Read More
  5. [linux] 계정관리하기(내공쌓기)

    Date2003.04.23 CategorySystem/OS Byhooni Views13165
    Read More
  6. [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치)

    Date2013.04.23 CategorySystem/OS Byhooni Views13067
    Read More
  7. [linux] Proftpd 설치 가이드

    Date2003.04.23 CategorySystem/OS Byhooni Views13030
    Read More
  8. [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법

    Date2003.04.23 CategoryDevelop Byhooni Views13029
    Read More
  9. [linux] ipfwadm를 이용한 패킷필터링(구버전)

    Date2003.04.23 CategorySystem/OS Byhooni Views13025
    Read More
  10. [linux] DHCP(Dynamic Host Configuration Protocol) 서버

    Date2003.04.23 CategorySystem/OS Byhooni Views13025
    Read More
  11. [js] AngularJS를 소개합니다.

    Date2014.01.06 CategoryDevelop Byhooni Views13017
    Read More
  12. [php] 심플한 게시판 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views12995
    Read More
Board Pagination Prev 1 ... 24 25 26 27 28 29 30 31 32 33 ... 98 Next
/ 98