I have this simple VBScript
that sends an HTTP POST
request and reads the returning HTML
response.
Function httpPOST(url, body, username, password )
Set Http = CreateObject("Msxml2.ServerXMLHTTP")
Http.Open "POST", url, False, username, password
Http.setRequestHeader _
"Content-Type", _
"application/x-www-form-urlencoded"
Http.send body
pagestatus = Http.status
if pagestatus<> "200" then
httpPOST="Error:"& pagestatus
else
'httpPOST = Http.ResponseBody
'httpPOST = Http.responseText
Set objXMLDoc = CreateObject("MSXML.DOMDocument")
objXMLDoc.async = False
objXMLDoc.validateOnParse = False
objXMLDoc.load(Http.ResponseBody)
Set objNode = objXMLDoc.selectSingleNode("/html/body/center/img")
httpPost = objNode.getAttribute("alt")
end if
End Function
The HTML
response format is the following:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>---</title>
</head>
<body>
<center>
<img alt="You are now connected" src="pages/GEN/connected_gen.png">
</center>
</body>
</html>
The issue with this script is that it always returns Error: Object required: 'objNode'
I have tried so many variations of XML
parsers, and finally gave up for every time I got the same error related to XML
objects.