Forum Moderators: open

Message Too Old, No Replies

getting xml document into variable

I am trying to parse a remote xml document

         

dtgorm

1:42 am on Oct 6, 2005 (gmt 0)



Ok, I have code on my website to get the response of data sent to a remote site. The data on the remote site is an xml page.

The problem I am having is i keep getting the error

################################################
Microsoft VBScript runtime error '800a01a8'

Object required: 'xmlDoc.selectSingleNode(...)'

/radio/req/req.asp, line 53
################################################

Any ideas where my XML code might be wrong? Am I not using the correct syntax for xml.responseText? What about xml.responseXML.XML? I dont know what would go here since i cant find a reference on all available selections.

The code I am using is roughly...

host = Request.ServerVariables("REMOTE_ADDR")

requests = "/req/?songID=" & songID & "&host=" & Server.URLEncode(host) & _
" HTTP\1.0" & VbCrlf & VbCrLf

Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://" & samhost & ":" & samport & requests, False

xmldata = ""
If xml.readyState = 1 Then
xml.Send
xmldata = xml.responseText
Else
DoErr 803
End If

Set xml = Nothing
If xmldata = "" Then DoErr 804

'#################################
' Initialize data
'#################################
set xmlDoc = Server.createObject("Microsoft.XMLDOM")
xmlDoc.async = False
'xmlDoc.setProperty "ServerHTTPRequest", True
xmlDoc.load(xmldata)

response.write xmlDoc.selectSingleNode("REQUEST/status/code").Attributes.GetNamedItem("code").Text

Athenz

7:44 pm on Oct 18, 2005 (gmt 0)



My guess is that xmlDoc.selectSingleNode("REQUEST/status/code") returns null (no nodes were found). Make sure you are using the proper case (XPath is case sensitive) in your XPath statement and you are using the correct path to the "code" node. It would help if you posted the source xml document.