반응형
'api key
strKey = "your api key"
sGetGubun = Request("gubun") '초중고구분
sGetkeyword = Request("keyword") '검색어
rows = 0
If sGetGubun = "1" Then
sGetGubun = "midd_list" '중학교
Else
sGetGubun = "high_list" '고등학교
End If
if not IsNULL(sGetGubun) and len(sGetGubun) Then
cngSearch = server.URLEncode(sGetkeyword)
'주소 정보 가져오기
sPath = "http://www.career.go.kr/cnet/openapi/getOpenApi?apiKey="& strKey &""_
& "&svcType=api&svcCode=SCHOOL&perPage=100&contentType=xml&gubun="& sGetGubun &"&searchSchulNm="& cngSearch
Set oDOM = Server.CreateObject("Microsoft.XMLDOM")
with oDOM
.async = False ' 동기식 호출
.setProperty "ServerHTTPRequest", True ' HTTP로 XML 데이터 가져옴
.Load(sPath)
end with
Set ResultNodes = oDOM.selectNodes("//dataSearch")
if ResultNodes.Length > 0 Then
Set Nodes = oDOM.selectNodes("//content")
rows = Nodes.Length
Else
rows = 0
End If
Set ResultNodes = Nothing
sXmlText = ""
sXmlText = sXmlText & ""
If rows > 0 Then
sXmlText = sXmlText & ""
sXmlText = sXmlText & "" & rows & " "
For each SubNodes in Nodes
nSeq = SubNodes.getElementsByTagName("seq")(0).Text'고유번호
sRegion = SubNodes.getElementsByTagName("region")(0).Text'지역
sSchoolName = SubNodes.getElementsByTagName("schoolName")(0).Text'학교명
sAdres = SubNodes.getElementsByTagName("adres")(0).Text'주소
sXmlText = sXmlText & "- "
sXmlText = sXmlText & "
"
sXmlText = sXmlText & " "
sXmlText = sXmlText & " "
sXmlText = sXmlText & " "
sXmlText = sXmlText & " "
Next
sXmlText = sXmlText & " "
Else
sXmlText = sXmlText & ""
sXmlText = sXmlText & "" & rows & " "
sXmlText = sXmlText & " "
End If
Response.ContentType = "text/xml"
REsponse.WRite sXmlText
Response.End
End If
반응형
'프로그래밍 > ASP' 카테고리의 다른 글
| ASP 업/다운로드 용량제한 설정 IIS8 (0) | 2017.11.10 |
|---|---|
| asp xml 페이지 생성 (0) | 2017.03.27 |
| asp https redirect (0) | 2017.03.15 |
| asp 오류페이지 한글깨짐현상 (0) | 2017.02.20 |
| asp javascript json array parse 파싱 후 출력하기 (2) | 2016.12.22 |