<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.List" %> <%@page import="java.net.URL" %> <%@page import="org.jdom.Document" %> <%@page import="org.jdom.Element" %> <%@page import="org.jdom.input.SAXBuilder" %> <%@page import="org.xml.sax.*" %> <%@page import="java.text.*" %> <% List list = null; try { SAXBuilder parser = new SAXBuilder(); parser.setValidation(false); parser.setIgnoringElementContentWhitespace(true); URL url = new URL("http://www.kma.go.kr/wid/queryDFS.jsp?gridx=59&gridy=125"); InputSource is = new InputSource(url.openStream()); Document doc = parser.build(is); Element root = doc.getRootElement(); Element channel = root.getChild("body"); list = channel.getChildren("data"); %> <% Element el = (Element)list.get(0); %>
<% }catch(Exception e){ e.getStackTrace(); }