Language/ASP | Posted by 아키텍처 2012. 4. 24. 15:17

ASP에서 XML파일 읽기

 
 

▣ ASP에서 XML파일 읽기

 

ASP에서 XML파일의 정보를 읽어오는 소스예제입니다.

 

Ex)

 Dim bcdcd_, name_, content_, imgname_
 Function designmenu(sort)

  Dim oDOM, url, Nodes, SubNodes, de_length
  Dim i
  url = "juuun.asp"
  Set oDOM = Server.CreateObject("Microsoft.XMLDOM")
  with oDOM
   .async = False
   .setProperty "ServerHTTPRequest", True
   .Load(url)
  end with
  
  de_length = CInt(oDOM.getElementsByTagName(sort).length)
  
  ReDim bcdcd_(de_length), name_(de_length), content_(de_length), imgname_(de_length)

  if oDOM.Load(url) Then
   Set Nodes = oDOM.getElementsByTagName(sort)
   i = 0
   For each SubNodes in Nodes
    bcdcd_(i) = SubNodes.getElementsByTagName("bcdcd")(0).Text
    name_(i) = SubNodes.getElementsByTagName("name")(0).Text
    content_(i) = SubNodes.getElementsByTagName("content")(0).Text
    imgname_(i) = SubNodes.getElementsByTagName("imgname")(0).Text
    i = i+1
   Next
  End If

  Set Nodes = Nothing
  Set oDOM = Nothing 

 End Function

-------------------------------------------------------------------------------------------------------

url = "juuun.asp" 대략소스

response.write "<?xml version=""1.0"" encoding=""euc-kr"" ?>" & Chr(13) & Chr(10)
 response.write "<designers>" & Chr(13) & Chr(10)
 
 If IsArray(aryTmpDesign_D90) Then
  For i=0 To UBound(aryTmpDesign_D90, 2)
  '브랜드코드;브랜드명;디자이너명
  
   response.write "<masstige>" & Chr(13) & Chr(10)
   response.write "<bcdcd>"& cutstring___(aryTmpDesign_D90(0,i),0) &"</bcdcd>" & Chr(13) & Chr(10)
   response.write "<bcdnm><![CDATA["& cutstring___(aryTmpDesign_D90(0,i),1) &"]]></bcdnm>" & Chr(13) & Chr(10)
   response.write "<name><![CDATA["& cutstring___(aryTmpDesign_D90(0,i),2) &"]]></name>" & Chr(13) & Chr(10)
   response.write "<content><![CDATA["&aryTmpDesign_D90(1,i)&"]]></content>" & Chr(13) & Chr(10)
   response.write "<imgname><![CDATA["&aryTmpDesign_D90(2,i)&"]]></imgname>" & Chr(13) & Chr(10)
   response.write "</masstige>"
  Next
 End If

 

response.write "</designers>"

Posted by 김준홍 (http://www.Juuun.com)