2010년 2월 12일 금요일

ASP 이용 XML Load

XML형식으로 전달되는 데이터 받기

 

<%

   Dim myXml, serverURL, Xadd, strcondition

   DIM DayTemp(3)

 

   set myXml = CreateObject("Microsoft.XMLDCOM")   ' XML 변수선언

   myXml.async = false

   myXml.setProperty "ServerHTTPRequest", True ' HTTP 경로

   serverURL = http://www.google.co.kr/ ' XML 파일 경로

 

   myXml.Load(serverURL)

 

   if myXml.parseError.errorCode <> 0 then  ' 데이터 Loading 확인

       response.write("ERROR")

   else

       set Xadd = myXml.documentElement.selectSingleNode("//current_conditions")  ' //current_conditions 노드 데이터 얻기

       strcondition = Xadd.selectSingleNode("condition").Attributes(0).text

      

   for i = 1 to 3
      Set Xadd = myXml.documentElement.selectSingleNode("//forecast_conditions["&i&"]")  ' //forecast_conditions["&i&"] 노드가 여러개일경우
      DayTemp(i) = Xadd.selectSingleNode("day_of_week").Attributes(0).text
   Next

 

   set Xadd = nothing

   set myXml = Nothing

%>

출처 : Tong - 공원님의 ┣ ★ 먹고사는일(Web)통

댓글 없음:

댓글 쓰기