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

时间:2022-05-21 01:33:14

i get an XML File from one Webservice and just need to print the whole XML File as recieved with Classic ASP.

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

XML File reading:

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)

Is there an easy way to print out the whole XML File like Response.Write xmlDoc.xml or an other way?

有没有一种简单的方法可以打印出像Response.Write xmlDoc.xml这样的整个XML文件或其他方式?

2 个解决方案

#1


5  

A lesser know alterative to Response.Write is:

对Response.Write的一个较少知道的改动是:

 Response.ContentType = "text/xml"
 Response.CharSet = "UTF-8"
 xmlDoc.save Response

This causes the xmlDoc write the xml directly to the response stream. This slightly more efficient than generating a Unicode string returned by the xml property only to re-encode it into the reponse stream with Response.Write.

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

#2


2  

bLoaded.xml will contain the loaded XML.

bLoaded.xml将包含加载的XML。

See the documentation for MSXML2.DOMDocument.

请参阅MSXML2.DOMDocument的文档。

So, yes:

Response.Write bLoaded.xml

Will output the XML. You may want to HTML encode it first and possibly pretty print it first.

将输出XML。您可能希望首先对其进行HTML编码,然后可能先将其打印出来。

#1


5  

A lesser know alterative to Response.Write is:

对Response.Write的一个较少知道的改动是:

 Response.ContentType = "text/xml"
 Response.CharSet = "UTF-8"
 xmlDoc.save Response

This causes the xmlDoc write the xml directly to the response stream. This slightly more efficient than generating a Unicode string returned by the xml property only to re-encode it into the reponse stream with Response.Write.

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

#2


2  

bLoaded.xml will contain the loaded XML.

bLoaded.xml将包含加载的XML。

See the documentation for MSXML2.DOMDocument.

请参阅MSXML2.DOMDocument的文档。

So, yes:

Response.Write bLoaded.xml

Will output the XML. You may want to HTML encode it first and possibly pretty print it first.

将输出XML。您可能希望首先对其进行HTML编码,然后可能先将其打印出来。