기상청 rss를 통해서 날짜 파싱하기
rss 클릭시 아래 링크로 이동을 한후 url정보를 가져온다.
http://www.kma.go.kr/wid/queryDFSRSS.jsp?zone=2647061000
<%
// 연결+옵션설정
String url = "";
url = "http://www.kma.go.kr/wid/queryDFS.jsp?gridx=97&gridy=79";
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = docBuilder.parse(url);
doc.setDocumentURI(url);
NodeList nodeMomList = doc.getDocumentElement().getChildNodes();
List xmlList = new ArrayList();
Node row = nodeMomList.item( 3 );
NodeList childList = row.getChildNodes();
Node rows = childList.item( 1 );
NodeList childLists = rows.getChildNodes();
for (int a=0; a<childLists.getLength(); a++){
Node tag_name = childLists.item(a); // xml name tag
if(tag_name.getNodeName().equals("hour")){ //시간
xmlList.add(tag_name.getTextContent());
}
if(tag_name.getNodeName().equals("temp")){ //온도
xmlList.add(tag_name.getTextContent());
}
if(tag_name.getNodeName().equals("wfKor")){ //한글
xmlList.add(tag_name.getTextContent());
}
if(tag_name.getNodeName().equals("wfEn")){ //영어
xmlList.add(tag_name.getTextContent());
}
if(tag_name.getNodeName().equals("pop")){ //강수량
xmlList.add(tag_name.getTextContent());
}
if(tag_name.getNodeName().equals("reh")){ //습도
xmlList.add(tag_name.getTextContent());
}
}
%>
<%
for(int i=0; i < xmlList.size(); i++){
out.print(xmlList.get(i));
}
%>
'Error > JAVA' 카테고리의 다른 글
getoutputstream() has already been called for this response (0) | 2019.09.09 |
---|---|
[Error] Operation not allowed after ResultSet closed (1) | 2018.02.02 |
cannot be resolved to a variable (0) | 2017.12.02 |
[error] Double Submit Preventer parameter isn't set. Check JSP. (0) | 2016.10.13 |
[ERROR] varchar 값을 JDBC 데이터 형식 INTEGER(으)로 변환하는 동안 오류가 발생했습니다. (0) | 2012.02.10 |