Alex Wolff
2005-07-12 18:28:02 UTC
Hello,
All code is at the bottom of message. I need to programmatically call an
html form, check some boxes and then submit the form, and finally parse the
returned page again. I am thinking I need to use XMLHTTPREQUEST then load
the resulting HTML as a DOM document then step thru the controls and do my
thing. Problem is I am getting an error when I load the form: "XML document
must have top level element". I do not have access to the original form
since its a private website. When I do "Debug.Print XMLHTTP.ResponseText" I
do see all the HTML is correctly there. Is there another of doing what I
need to do? I guess the DOM is complaining that the HTML may not be
compliant!?
Thanks in Advanced!!!
Dim XMLHTTP As New MSXML2.XMLHTTP40
Dim xmldoc As New MSXML2.DOMDocument40
xmldoc.async = False
xmldoc.resolveExternals = False
XMLHTTP.Open "GET", "http://my.url.com/forms/NC.htm", False
XMLHTTP.send
Debug.Print XMLHTTP.responseText
xmldoc.loadXML (XMLHTTP.responseXML.xml)
If (xmldoc.parseError.errorCode <> 0) Then
Dim Myerr
Set Myerr = xmldoc.parseError
MsgBox ("You Have Error" & Myerr.reason)
Else
Set ObjNodeList = xmldoc.getElementsByTagName("Message")
MsgBox (ObjNodeList.Item(0).Text)
End If
End Sub
All code is at the bottom of message. I need to programmatically call an
html form, check some boxes and then submit the form, and finally parse the
returned page again. I am thinking I need to use XMLHTTPREQUEST then load
the resulting HTML as a DOM document then step thru the controls and do my
thing. Problem is I am getting an error when I load the form: "XML document
must have top level element". I do not have access to the original form
since its a private website. When I do "Debug.Print XMLHTTP.ResponseText" I
do see all the HTML is correctly there. Is there another of doing what I
need to do? I guess the DOM is complaining that the HTML may not be
compliant!?
Thanks in Advanced!!!
Dim XMLHTTP As New MSXML2.XMLHTTP40
Dim xmldoc As New MSXML2.DOMDocument40
xmldoc.async = False
xmldoc.resolveExternals = False
XMLHTTP.Open "GET", "http://my.url.com/forms/NC.htm", False
XMLHTTP.send
Debug.Print XMLHTTP.responseText
xmldoc.loadXML (XMLHTTP.responseXML.xml)
If (xmldoc.parseError.errorCode <> 0) Then
Dim Myerr
Set Myerr = xmldoc.parseError
MsgBox ("You Have Error" & Myerr.reason)
Else
Set ObjNodeList = xmldoc.getElementsByTagName("Message")
MsgBox (ObjNodeList.Item(0).Text)
End If
End Sub