<!--#include virtual=
"/include/aspJSON1.13.asp"
-->
Set
oJSON =
New
aspJSON
strKey = request(
"weatherKey"
)
If
strKey =
""
Then
strKey =
"1100000000"
End
If
RSSData = GetXmlHttp(RSSUrl)
Set
xmlDoc = Server.CreateObject(
"MSXML2.DOMDOCUMENT.4.0"
)
xmlDoc.async = false
xmlDoc.loadXml RSSData
newsLength = xmlDoc.selectNodes(
"//data"
).length
Set
SelectNodes = xmlDoc.SelectNodes(
"//data"
)
Dim
strTemp
Dim
strWeather
Set
oJSON.data(
"weatherData"
) = oJSON.Collection()
For
x = 0
To
newsLength-1
If
SelectNodes(x).selectSingleNode(
"day"
).Text > 0 then
If
SelectNodes(x).selectSingleNode(
"hour"
).Text = 12
Then
Set
newitem = oJSON.AddToCollection(oJSON.data(
"weatherData"
))
newitem.add
"hour"
, SelectNodes(x).selectSingleNode(
"hour"
).Text
newitem.add
"day"
, SelectNodes(x).selectSingleNode(
"day"
).Text
newitem.add
"temp"
, fn_Weather_Cal(SelectNodes(x).selectSingleNode(
"temp"
).Text)
newitem.add
"tmx"
, fn_Weather_Cal(SelectNodes(x).selectSingleNode(
"tmx"
).Text)
newitem.add
"tmn"
, fn_Weather_Cal(SelectNodes(x).selectSingleNode(
"tmn"
).Text)
newitem.add
"sky"
, SelectNodes(x).selectSingleNode(
"sky"
).Text
newitem.add
"pty"
, SelectNodes(x).selectSingleNode(
"pty"
).Text
newitem.add
"wfKor"
, SelectNodes(x).selectSingleNode(
"wfKor"
).Text
newitem.add
"wfEn"
, SelectNodes(x).selectSingleNode(
"wfEn"
).Text
newitem.add
"pop"
, SelectNodes(x).selectSingleNode(
"pop"
).Text
newitem.add
"time"
, FormatDateTime(DateAdd(
"d"
,SelectNodes(x).selectSingleNode(
"day"
).text,now()),1) &
" "
&SelectNodes(x).selectSingleNode(
"hour"
).Text &
"시"
newitem.add
"imgWeather"
, fn_Weather_img(SelectNodes(x).selectSingleNode(
"wfKor"
).text, SelectNodes(x).selectSingleNode(
"wfEn"
).text)
End
if
Else
If
strTemp =
"chk"
Then
Else
Set
newitem = oJSON.AddToCollection(oJSON.data(
"weatherData"
))
newitem.add
"hour"
, SelectNodes(x).selectSingleNode(
"hour"
).Text
newitem.add
"day"
, SelectNodes(x).selectSingleNode(
"day"
).Text
newitem.add
"temp"
, fn_Weather_Cal(SelectNodes(x).selectSingleNode(
"temp"
).Text)
newitem.add
"tmx"
, fn_Weather_Cal(SelectNodes(x).selectSingleNode(
"tmx"
).Text)
newitem.add
"tmn"
, fn_Weather_Cal(SelectNodes(x).selectSingleNode(
"tmn"
).Text)
newitem.add
"sky"
, SelectNodes(x).selectSingleNode(
"sky"
).Text
newitem.add
"pty"
, SelectNodes(x).selectSingleNode(
"pty"
).Text
newitem.add
"wfKor"
, SelectNodes(x).selectSingleNode(
"wfKor"
).Text
newitem.add
"wfEn"
, SelectNodes(x).selectSingleNode(
"wfEn"
).Text
newitem.add
"pop"
, SelectNodes(x).selectSingleNode(
"pop"
).Text
newitem.add
"time"
, FormatDateTime(DateAdd(
"d"
,SelectNodes(x).selectSingleNode(
"day"
).text,now()),1) &
" "
&SelectNodes(x).selectSingleNode(
"hour"
).Text &
"시"
newitem.add
"imgWeather"
, fn_Weather_img(SelectNodes(x).selectSingleNode(
"wfKor"
).text, SelectNodes(x).selectSingleNode(
"wfEn"
).text)
strTemp =
"chk"
End
if
End
If
Next
Set
SelectNodes =
Nothing
Set
xmlDoc =
Nothing
Function
GetXmlHttp(XMLURL)
Set
xmlHttp = Server.CreateObject(
"MSXML2.ServerXMLHTTP"
)
xmlHttp.Open
"POST"
, XMLURL,
False
xmlHttp.Send
GetXmlHttp = xmlHttp.responseText
Set
xmlHttp =
Nothing
End
Function
Function
fn_Weather_Cal(strTemp)
Dim
strCal
strCal =
"-"
select case strTemp
case
"-999.0"
strCal =
"-"
Case
Else
strCal = strTemp
End
Select
fn_Weather_Cal = strCal
End
Function
Function
fn_Weather_img(strKor, strEn)
select case strEn
case
"Clear"
case
"Partly Cloudy"
case
"Mostly Cloudy"
case
"Cloudy"
case
"Rain"
case
"Snow"
case
"Snow/Rain"
case
"Rain/Snow"
case
"구름많고 비"
case
"구름많고 눈"
case
"구름많고 눈/비"
case
"구름많고 비/눈"
case
""
fn_Weather_img =
"NoImage"
case else
fn_Weather_img =
"NoImage"
end select
End
Function
Response.ContentType =
"application/json"
Response.Write oJSON.JSONoutput()