[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

Using the MSHTML collection with a string containing HTML

I'm request html using the following method,

      Dim sResult As String
                        Dim oHttp As HttpWebRequest
                        Dim objResponse As WebResponse
                        Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(EventUrl)

                        objRequest.Method = "GET"
                        objRequest.Timeout = 120000 ' 20 sec.
                        objResponse = objRequest.GetResponse

                        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.UTF7)

                        sResult = sr.ReadToEnd()
                        ' Close and clean up the StreamReader


                        Dim DOCHTML As String
                        doc = DirectCast(sResult, mshtml.HTMLDocument)
                        dochtml = doc.documentElement.innerHTML()

This doesn't seem to convert the html string so that it can be used with the mshtml collection. If I choose to display the html after it finishes with debug.write(sresult.tostring) it will output to the debug window. But when I try to output it with  Debug.Write(DOCHTML) it won't work. 500 points because I'm trying to finish the development of this application within the next few weeks. thanks guys.

  • 4
1 Solution
Bob LearnedCommented:
Here is a class that I use, instead of an HttpWebRequest to parse an HTML document:


JPERKS1985Author Commented:
Hmm problem is I need to parse out different controls , heres part of the code I'm using

        For Each elm In all
            strName = elm.getAttribute("NAME")
            strId = elm.id
            strvalue = elm.innerText
            strType = elm.getAttribute("type")

Anyway to convert my string to wokr with that?
JPERKS1985Author Commented:
nevermind I got it working thanks.
JPERKS1985Author Commented:
Now is there a way to use this source to pass cookies? Also is there a way for proxy support? Thats why I was using httprequest
JPERKS1985Author Commented:
Better yet, how do I extract the cookies and route the request for the page through a proxy?

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now