我在ASP页面中有下一个代码,但我想检索外部xml文件。有谁知道我该怎么做?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("resp2.xml"))
'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("resp.xsl"))
'Transform file
Response.Write(xml.transformNode(xsl))
%>
答案 0 :(得分:2)
尝试以下
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.setProperty "ServerHTTPRequest", true
xml.async = false
xml.validateOnParse = false
xml.load("http://yourdomain.com/resp2.xml")
答案 1 :(得分:1)
尝试使用ServerXMLHTTP对象:
Dim xmlReq, sResponse
Set xmlReq = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
Call xmlReq.open("GET", "http://host/dir/page.xml")
Call xmlReq.send()
If (xmlReq.status = 200) Then
sResponse = xmlReq.responseText
End If