출처 : http://blog.naver.com/forioso/10093592150
ASP 에서 XML 파싱하는 클래스인데 상당히 깔끔한 클래스다. 주석에 달려있는 이수환님 감사합니다.
<%
'------------------------------------------------
' XML Parse 용 클래스
' 필요한 핵심부분만 만듬 2010. 06.18 이수환
'------------------------------------------------
Class XMLDOMParse
Private m_DOM ' XMLDOM 객체
' ---------------------- 생성자 -----------------------
Private Sub Class_Initialize()
Set m_DOM = Server.CreateObject("Microsoft.XMLDOM")
End Sub
' ---------------------- 소멸자 -----------------------
Private Sub Class_Terminate()
Set m_DOM = Nothing
End Sub
' ------------------- Property Get --------------------
Public Property Get TagText(tagName, index)
Dim Nodes
Set Nodes = m_DOM.getElementsByTagName(tagName)
TagText = Nodes(index).Text
Set Nodes = Nothing
End Property
' ------------------- Property Get --------------------
Public Property Get AttributeText(tagName, index , item)
AttributeText = m_DOM.getElementsByTagName(tagName)(index).attributes.getNamedItem(item).Text
End Property
' ------------------- 원격 XML 읽기 --------------------
Public Function LoadHTTP(url)
with m_DOM
.async = False ' 동기식 호출
.setProperty "ServerHTTPRequest", True ' HTTP로 XML 데이터 가져옴
LoadHTTP = .Load(url)
end with
End Function
' ------------------- XML 읽기 --------------------
Public Function Load(strXML )
with m_DOM
.async = False ' 동기식 호출
.loadXML(strXML)
end with
End Function
' ------------------- HTML 페이지 읽기 --------------------
Public Function OpenHttp( PgURL)
Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlHttp.Open "GET", PgURL, False
xmlHttp.Send
Ret = xmlHttp.ResponseText
Set xmlHttp = Nothing
OpenHttp = Ret
End Function
End Class
%>
1>
Set xml = new XMLDOMParse
xml.LoadHTTP(http://domain.com/getval.asp?pc_a=" & sPC)
ErrState = xml.TagText("ERROR",0)
2>
Set xml = new XMLDOMParse
Data = xml.OpenHttp("http://domain.com/getcid.asp?filename=" & sFileName )
xml.load(Data)
gCID = xml.TagText("CID",0)
[출처] ASP XML 파싱함수|작성자 사랑굳
'Development > Visual Basic | VBScript | ASP' 카테고리의 다른 글
ADO DataType (SQL → ADO) (0) | 2012.02.04 |
---|---|
IIS (7.0 이하 버전 기준 확장자 매핑) (0) | 2011.04.07 |
윈도우 2008서버에서 ASP로 이메일 발송 - CDO.Message (0) | 2011.01.10 |
VBScript Functions (0) | 2010.12.13 |
ABC 업로드 컴포넌트 속성 (0) | 2010.12.01 |
댓글