以下示例如何取得所有node及它们的值:
TRY:
<%
Set objXML = server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "Get", "http://members.macauslot.com/nba/html/result/live.xml",False
objXML.send
Banner = objXML.responseText
Set objXML = nothing
Set xml = Server.CreateObject("MSXML.DOMDocument")
xml.async = False
xml.loadXML Banner
Set root = xml.documentElement
for i = 0 to (root.childNodes.length-1)
for n = 0 to (root.childNodes.item(i).childNodes.length-1)
response.write root.childNodes.item(i).childNodes.item(n).baseName&":"
response.write root.childNodes.item(i).childNodes.item(n).text&"<br>"
next
next
for i = 0 to (root.childNodes.length-1)
response.write root.childNodes.item(i).childNodes.item(4).baseName&":"
response.write root.childNodes.item(i).childNodes.item(4).text&"<br>"
next
TRY:
<%
Set objXML = server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "Get", "http://members.macauslot.com/nba/html/result/live.xml",False
objXML.send
Banner = objXML.responseText
Set objXML = nothing
Set xml = Server.CreateObject("MSXML.DOMDocument")
xml.async = False
xml.loadXML Banner
n = xml.selectNodes("//LIVESCORE/DATA/ROW").length
for i = 0 to n-1
test = xml.selectSingleNode("//LIVESCORE/DATA/ROW["&i&"]").getAttribute("fid")
response.write test&";"
next
Set xml=Nothing %>
参考:
xmlfile="http://members.macauslot.com/nba/html/result/live.xml"
Set xml = Server.CreateObject("MSXML.DOMDocument")
xml.async = False
xml.load xmlfile
n = xml.selectNodes("//LIVESCORE/DATA/ROW").length
for i = 0 to n-1
fid = xml.selectSingleNode("//LIVESCORE/DATA/ROW[0]").getAttribute("fid")
next
<%
function codeChange(str)
finalstr = ""
for i = 1 to lenb(str)
icharcode = ascb(midb(str,i,1))
if icharcode < &H80 then
finalstr = finalstr & chr(icharcode)
else
inextcode = ascb(midb(str,i+1,1))
finalstr = finalstr & chr(clng(icharcode) * &H100 + cint(inextcode))
i = i + 1
end if
next
codeChange = finalstr
end function
function getStr(content,bstr,estr)
Pstart=instr(content,bstr)+len(bstr)
Slen=instr(content,estr)-Pstart
tmpstr=mid(content,Pstart,Slen)
tmpstr=replace(tmpstr,vbcrlf,"")
tmpstr=replace(tmpstr,chr(10),"")
getStr=trim(tmpstr)
end function
set connect = createobject("Microsoft.XMLHTTP")
call connect.open ("GET","http://members.macauslot.com/nba/html/result/live.xml",false)
connect.send()
code = codeChange(connect.responsebody)
code=getstr(code,"<DATA>","</DATA>")
code=replace(code,"<","")
Rows=split(code,">")
for i=0 to ubound(Rows)-1
response.write "第"& i+1 &"列sid=" & getstr(Rows(i),"sid=""",""" m=")&"<br>"
next
%>