Use the xmldom method to open the xml file. If it is local, there is no problem. Just use the Server.MapPath("xml.xml") method. At this time, the content can be analyzed normally, but the xml content will not be displayed when using the url directly (in XMLDOM It indicates that URL mode is supported). After some research, I found that you can use the XMLHTTP method to obtain XML and then analyze it. The code is as follows:
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET"," http://www.downcodes.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("The document is ready. Status: "& 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("The document is not ready yet. Status: "& xml.ReadyState &"<br>")
End If
Set http=Nothing
Set xml=Nothing
The content of the xml.xml document is as follows:
<?xml version="1.0" encoding="utf-8"?>
<channel>
<item>
<title>Test document 1</title>
<link>http://localhost/</link>
</item>
<item>
<title>Test Document 2</title>
<link>http://localhostindex.asp</link>
</item>
</channel>