Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET","http://www.webjx.com/xml.XML",False
http.send
Set xml=Server.CreateObject("Microsoft.XMLDOM")
XML.Async=False
XML.ValidateOnParse=False
xml.Load(http.ResponseXML)
If XML.ReadyState>2 Then
Response.Write("文檔已經准備就緒。狀態:"& XML.ReadyState &"<br>")
Set item=XML.getElementsByTagName("item")
For i=0 To (item.Length-1)
Set title=item.Item(i).getElementsByTagName("title")
Set link=item.Item(i).getElementsByTagName("link")
Response.Write("<a href="""& link.Item(0).Text &""">"& title.Item(0).Text &"</a><br>")
Next
Else
Response.Write("文檔還未准備就緒。狀態:"& XML.ReadyState &"<br>")
End If
Set http=Nothing
Set XML=Nothing
xml.XML文檔的內容如下:
<?XML version="1.0" encoding="utf-8"?>
<channel>
<item>
<title>測試文檔1</title>
<link>http://localhost/</link>
</item>
<item>
<title>測試文檔2</title>
<link>http://localhostindex.ASP</link>
</item>
</channel>