Parse XML error in VBScript

Cobra

New Member
I have this simple \[code\]VBScript\[/code\] that sends an \[code\]HTTP POST\[/code\] request and reads the returning \[code\]HTML\[/code\] response.\[code\]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 ifEnd Function\[/code\]The \[code\]HTML\[/code\] response format is the following:\[code\]<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="http://stackoverflow.com/questions/12749035/pages/GEN/connected_gen.png"> </center> </body></html>\[/code\]The issue with this script is that it always returns \[code\]Error: Object required: 'objNode'\[/code\]I have tried so many variations of \[code\]XML\[/code\] parsers, and finally gave up for every time I got the same error related to \[code\]XML\[/code\] objects.
 
Back
Top