使用经典ASP编写完整的XML文件

Ste*_*fan 3 xml asp-classic

我从一个Web服务获得一个XML文件,只需要打印经典ASP收到的整个XML文件.

XML文件读取:

strURL = "http://www.google.com/ig/api?weather=" & weather & "&hl=" & hl

set xmlDoc = createObject("MSXML2.DOMDocument")
xmlDoc.async = False
xmlDoc.setProperty "ServerHTTPRequest", true
bLoaded = xmlDoc.load(strURL)
Run Code Online (Sandbox Code Playgroud)

有没有一种简单的方法来打印整个XML文件,如Response.Write xmlDoc.xml或其他方式?

Ant*_*nes 5

对Response.Write的一个较少知道的替代是:

 Response.ContentType = "text/xml"
 Response.CharSet = "UTF-8"
 xmlDoc.save Response
Run Code Online (Sandbox Code Playgroud)

这会导致xmlDoc将xml直接写入响应流.这比生成xml属性返回的Unicode字符串稍微更高效,只是为了将其重新编码为响应流Response.Write.