본문 바로가기
Java+Jsp

xml 읽어오기

by xfree302 2009. 11. 2.
반응형


<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="org.jdom.Document"%>
<%@page import="org.jdom.JDOMException"%>
<%@page import="org.jdom.input.SAXBuilder"%>
<%@page import="org.jdom.xpath.XPath"%>
<%@page import="java.net.URL"%>
<%
 String result="";
  
 //String filename = "sample.xml";
 //Document document = new SAXBuilder().build(new FileInputStream(filename));
 //String data0 = "//list/aa";

 String filename = "http://www.kstamp.go.kr/sp/rs/todaystamp.rss.jsp";
 Document document = new SAXBuilder().build(new URL(filename));
 String data0 = "//channel/item/stampimage";
 
 //String data1 = "//list/aa";
 //String data2 = "//list/bb";
 //String data3 = "//list/cc";
 
 XPath xPath = XPath.newInstance(data0);
 result = xPath.valueOf(document);

 System.out.println(result);

%>

<img src="<%= result%>">

반응형

'Java+Jsp' 카테고리의 다른 글

jsp ftp (Commons net)  (0) 2010.02.18
jsp file upload (MultipartRequest )  (0) 2010.02.18
java 디컴파일러 JAD, JADClipse  (0) 2009.11.13
엑셀 저장하기  (0) 2009.10.29
페이징 처리  (0) 2009.10.29