Use the xmldom method to open the XML file. If the file is local, the server is used. mappath ("XML. XML ") method, the content can be analyzed normally, but the XML content is not displayed directly with the URL (the URL method is supported in xmldom ), later, I found that the XML can be obtained using XMLHTTP and then analyzed. The Code is as follows:
Set HTTP = server. Createobject ("Microsoft. XMLHTTP ")
HTTP. Open "get", "http: // localhost/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>