XMLDOM的方法是在 l-blog 的作者 卫慧杰那里找到的,一直没听说这种方法,顺便整理一下adodb.stream的生成方法。
1.使用XMLDOMdim xmlString
xmlString="<html>" & chr(10) & "<head>" & chr(10) & "<title>test</title>" & chr(10) & "</head>" & chr(10) & "<body>" & chr(10) & "<p><img src=""http://www.webjx.com/htmldata/2007-03-25/http://www.webjx.com/htmldata/2007-03-25/test.gif"" /></p>" & chr(10) & "</body>" & chr(10) & "</html>"
dim xmlDoc
set xmlDoc = server.createObject("Msxml2.DOMDocument")
xmlDoc.loadXml(xmlString)
xmlDoc.save(server.mappath("test.htm"))
set xmlDoc=nothing
原文有一点点小错误,<img src="http://www.webjx.com/htmldata/2007-03-25/http://www.webjx.com/htmldata/2007-03-25/test.gif" />这段应该是<img src=""http://www.webjx.com/htmldata/2007-03-25/http://www.webjx.com/htmldata/2007-03-25/test.gif"" />可能一时疏忽
2.使用XMLDOM,adodb.streamdim htmlString
htmlString="<html>" & chr(10) & "<head>" & chr(10) & "<title>test</title>" & chr(10) & "</head>" & chr(10) & "<body>" & chr(10) & "<p><img src=""http://www.webjx.com/htmldata/2007-03-25/http://www.webjx.com/htmldata/2007-03-25/test.gif"" /></p>" & chr(10) & "</body>" & chr(10) & "</html>"
set maker=server.CreateObject("adodb.stream")
maker.Type=2 '以本模式读取
maker.mode=3
maker.charset="utf-8"
maker.open
maker.WriteText htmlString
maker.SaveToFile server.MapPath("test.htm"),2
maker.flush
maker.Close
set maker=nothing