51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
example usage:
|
|
<%
|
|
Dim i, a, strXMLPath, strXMLExpression
|
|
|
|
strXMLPath = Server.MapPath("/aspemporium/examples/xmlcatalog/database.xml")
|
|
strXMLExpression = "/CATALOG/MOVIE[RUNNINGTIME $gt$ 100]/RATING | " & _
|
|
"/CATALOG/MOVIE[RUNNINGTIME $gt$ 100]/TITLE"
|
|
a = XMLRead( strXMLPath, strXMLExpression )
|
|
|
|
For i = 0 To UBound(a) - 1
|
|
Response.Write a(i) & "<BR>"
|
|
Next
|
|
%>
|
|
source code:
|
|
<%
|
|
Private Function XMLRead(ByVal xmlfilepath, ByVal expression)
|
|
Dim temp, item, tmp, objXML, tmpArray
|
|
On Error Resume Next
|
|
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
|
|
objXML.Load( xmlfilepath )
|
|
If Err Then
|
|
On Error GoTo 0
|
|
Err.Raise 5140, "XMLRead Function", _
|
|
"Specified XML File Not Found."
|
|
Err.Clear
|
|
XMLRead = Null
|
|
Set objXML = Nothing
|
|
Exit Function
|
|
End If
|
|
Set temp = objXML.documentElement.selectnodes( expression )
|
|
If Err Then
|
|
On Error GoTo 0
|
|
Err.Raise 5140, "XMLRead Function", _
|
|
"Expression argument produced an error."
|
|
Err.Clear
|
|
XMLRead = Null
|
|
Set objXML = Nothing
|
|
Exit Function
|
|
End If
|
|
For Each item In temp
|
|
tmp = tmp & item.text & vbCrLf & "/" & vbCrLf
|
|
Next
|
|
Set temp = Nothing
|
|
Set objXML = Nothing
|
|
tmpArray = Split( tmp, vbCrLf & "/" & vbCrLf )
|
|
XMLRead = tmpArray
|
|
On Error GoTo 0
|
|
End Function
|
|
%>
|
|
|