网络编程
位置:首页>> 网络编程>> XML编程>> 使用XMLhttp生成html页面

使用XMLhttp生成html页面

  发布时间:2007-08-17 11:21:00 

标签:XML,XMLhttp,html

本文介绍了使用XMlhttp技术来生成html页面,值得借鉴。相关函数:


<% 
’定义xmlhttp 
function GetXmlText(Url) 
dim GetXmlHttp 
set GetXmlHttp=server.Createobject("Microsoft.XMLHTTP") 
GetXmlHttp.open "Get",url,false,"","" GetXmlHttp.Send  
’GetXmlText=GetXmlHttp.Responsetext 
GetXmlText=GetXmlHttp.ResponseBody 
set GetXmlHttp=Nothing 
end function 
’转换为字符 
Function BytesToBstr(body,Cset)  
dim objstream  
set objstream = Server.CreateObject("adodb.stream")  
objstream.Type = 1  
objstream.Mode =3  
objstream.Open  
objstream.Write body  
objstream.Position = 0  
objstream.Type = 2  
objstream.Charset = Cset  
BytesToBstr = objstream.ReadText  
objstream.Close  
set objstream = nothing  
End Function 
’保存文件 
Sub SaveToFile(strBody,File)  
Dim objStream 
Set objStream = Server.CreateObject("ADODB.Stream") 
With objStream  
.Type = 2  
.Open  
.Charset = "GB2312"  
.Position = objStream.Size 
.WriteText = strBody  
.SaveToFile Server.MapPath(File),2  
.Close 
End With  
Set objStream = Nothing End Sub  
%> 


使用方法:


<%
SaveToFile BytesToBstr(GetXmlText("http://127.0.0.1/index.asp"),"GB2312"),"index.htm")
%> 


0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com