顯示某節點各個屬性和數據的FUNCTION:
Function showallnode(rootname,myXMLDOC)
if rootname<>"" then
set nodeobj=myXMLDOC.documentElement.selectSingleNode("//"&rootname&"")'當前結點對像
nodeAttributelen=myXMLDOC.documentElement.selectSingleNode("//"&rootname&"").attributes.length'當前結點屬性數
returnstring=returnstring&"<BR>節點名稱:"&rootname
if nodeobj.text<>"" then
returnstring=returnstring&"<BR>節點的文本:("&nodeobj.text&")"
end if
returnstring=returnstring&"<BR>{<BR>"
if nodeAttributelen<>0 then
returnstring=returnstring&"<BR>屬性數有 "&nodeAttributelen&" 個,分別是:"
end if
for i=0 to nodeAttributelen-1
returnstring=returnstring&"<li>"&nodeobj.attributes(i).Name&": "&nodeobj.getAttribute(nodeobj.attributes(i).Name)&" </li>"
next
if nodeobj.childNodes.Length<>0 then
if nodeobj.hasChildNodes() and lcase(nodeobj.childNodes.item(0).nodeName)<>"#text" then'是否有子節點
set childnodeobj=nodeobj.childNodes
childnodelen=nodeobj.childNodes.Length
returnstring=returnstring&"<BR><BR>有 "&childnodelen&" 個子節點;<BR>分別是: "
for i=0 to childnodelen-1
returnstring=returnstring&"<li>"&childnodeobj.item(i).nodeName&"</li>"
next
end if
end if
returnstring=returnstring&"<BR>}<BR>"
response.write returnstring
set nodeobj=nothing
end if
End Function
可以這樣用:
If XMLhttp.Status = 200 Then
Set xmlDOC = server.CreateObject("MSXML.DOMDocument")
xmlDOC.load(xmlhttp.responseXML)
showallnode "LoginByAccountResponse",XMLDOC’調用SHOWALLNODE
Set XMLDOC = nothing
Else
Response.Write XMLhttp.Status&" "
Response.Write XMLhttp.StatusText
End if
POST:
url = "http://s/" SoapRequest="username="&username&"&password="&passWord Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP") xmlhttp.Open "POST",url,false xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"’注意 xmlhttp.setRequestHeader "HOST"," " xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest) xmlhttp.Send(SoapRequest) Response.Write xmlhttp.Status&” ” Response.Write xmlhttp.StatusText Set xmlhttp = Nothing 'POST If xmlhttp.Status = 200 Then Set xmlDOC = server.CreateObject("MSXML.DOMDocument") xmlDOC.load(xmlhttp.responseXML) showallnode "string",xmlDOC'調用SHOWALLNODE Set xmlDOC = nothing Else Response.Write xmlhttp.Status&" " Response.Write XMLhttp.StatusText End if