用xmlhttp请求xml格式的asp文件时不能返回值。
ttt.asp格式
<?xml version="1.0" encoding="utf-8"?>
<FansgivingDatabase>
<Booking records="1">
<FLD fldid="1">AAA</FLD>
<FLD fldid="2">BBB</FLD>
<FLD fldid="3">CCC</FLD>
<FLD fldid="4">DDD</FLD>
</Booking>
</FansgivingDatabase>
load.asp
'读取XML中数据,写入数据库
Function UpdateXMLToDatabase(LinkURL)
'on error resume next
Dim objXML, loadResult
Dim http
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET",LinkURL,False '"http://www.fansgiving.com/fansgiving/database/test.xml"
http.send
Set objXML = Server.CreateObject("Msxml2.DOMDocument")
objXML.async = False
objXML.ValidateOnParse=False
objXML.load(http.ResponseXML)
If objXML.ReadyState>2 Then
Response.Write("文档已经准备就绪。状态:"& objXML.ReadyState &"<br>")
Set item1=objXML.getElementsByTagName("FansgivingDatabase")
For i=0 To (item1.Length-1)
Set Booking=item1.Item(i).getElementsByTagName("Booking")
Response.Write(Booking.Item(0).Text)
Next
Else
Response.Write("文档还未准备就绪。状态:"& objXML.ReadyState &"<br>")
End If
Set http=Nothing
Set objXML=Nothing
end function
call UpdateXMLToDatabase("http://localhost/database/ttt.asp")
response.write("<br>OK")
response.end()
如果用ttt.xml可以读取
结果如下:
文档已经准备就绪。状态:4
AAA BBB CCC DDD
OK
但是用ttt.asp就读不出来了。
晕头转向中
结果如下:
文档已经准备就绪。状态:4
OK
哪位大哥指点迷津,多谢了