Contents

조회 수 13215 댓글 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] 아이폰용 앱 오픈 소스들

    Date2013.04.23 CategoryDevelop Byhooni Views467106
    Read More
  2. [ios] 언어, 지역, 국가 설정 가져오기

    Date2014.05.12 CategoryDevelop Byhooni Views269920
    Read More
  3. 자주 쓰는 Docker 명령어 alias

    Date2020.01.10 CategoryDevelop Byhooni Views269679
    Read More
  4. [ios] Start developing your navigation app for CarPlay without enrollment

    Date2020.02.22 CategoryDevelop Byhooni Views124797
    Read More
  5. [android] 만화 어플 소스코드

    Date2013.04.23 CategoryDevelop Byhooni Views92838
    Read More
  6. 레고 마인드스톰 NXT 수도쿠, 큐브 소스코드..

    Date2013.04.23 CategoryDevelop Byhooni Views81429
    Read More
  7. [c#] Hashtable <-> Json (dll 포함)

    Date2013.04.23 CategoryDevelop Byhooni Views80655
    Read More
  8. [C#] MD5, SHA1 해시 & 인코딩

    Date2013.04.23 CategoryDevelop Byhooni Views77857
    Read More
  9. [android] 점심 해결 앱 소스 코드 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views76397
    Read More
  10. [json] 종결자 (설명과 웹, C/C++/C# 프로그램 샘플 코드)

    Date2013.04.23 CategoryDevelop Byhooni Views71973
    Read More
  11. [android] keytool을 사용하여 키스토어 생성

    Date2013.04.23 CategoryDevelop Byhooni Views69515
    Read More
  12. [ios] Random Thoughts: Rand() vs. arc4random()

    Date2013.10.31 CategoryDevelop Byhooni Views68048
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 71 Next
/ 71