Results 1 to 3 of 3

Thread: is there an HTML Reader object? **resolved**

  1. #1

    Thread Starter
    Addicted Member WALDO's Avatar
    Join Date
    Aug 2002
    Location
    Swing of Prussia, PA
    Posts
    244

    is there an HTML Reader object? **resolved**

    I'm looking for an object that will let me supply it with some HTML code (submitted by the user) and return a collection of objects like the HTML DOM. I'm trying not to do this with a reg ex, but If I must, I will.

    For example:
    A user submits some HTML. It has some links in it. I want to be able to readjust those links as if by saying
    VB Code:
    1. 'Total psuedocode
    2. 'Take no stock in poor syntax
    3.  
    4. Dim objDoc As New HTMLDocumentReader 'I wish
    5. Dim colA As [i]Elements[/i]
    6.  
    7. colA = objDoc.document.getElementsByTagName("a")
    8. For i = 0 To colA.length - 1
    9.     colA(i).href= "MyHREF"
    10. Next
    Last edited by WALDO; Apr 21st, 2003 at 04:05 PM.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I haven't found one with .net yet (that doesn't mean it doesn't exist though). I settled on using the old COM parser for the things you are trying to do.

  3. #3

    Thread Starter
    Addicted Member WALDO's Avatar
    Join Date
    Aug 2002
    Location
    Swing of Prussia, PA
    Posts
    244

    Yo, I got it

    It kinda sux, but this is how I got it to run:
    I had to create 2 COM references. (Damn interop)
    MSHTML.dll
    SHDocVw.dll
    VB Code:
    1. Dim htmlDOM As IHTMLDocument2
    2.         Dim brwTest As New SHDocVw.InternetExplorer() 'WebBrowser()
    3.  
    4.         brwTest.Navigate("about:blank")
    5.         htmlDOM = brwTest.Document
    6.         'Load some user submitted source
    7.         htmlDOM.body.innerHTML = Request.Form("HTMLSource")
    8.  
    9.         'Play with some elements
    10.         Dim objI As IHTMLElement
    11.         For Each objI In htmlDOM.images
    12.             objI.src = "/KnowledgeBase/Support/4/test.gif"
    13.         Next
    14.  
    15.         Me.TextBox1.Text = htmlDOM.body.innerHTML
    16.  
    17.         htmlDOM = Nothing
    18.         brwTest.Dispose()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width