This should give you the basics, but the code in the article has some
issues.  Specifically, there are timing issues -- the document may not have
been loaded and parsed by the time the code starts to try to parse the HTML.

Using MSHTML and VB
http://abstractvb.com/code.asp?A=756

Make sure to follow the directions to add the References to the Project, or
it won't work.

Here's my take on the code:

    Dim Web As New SHDocVw.InternetExplorer
    Dim Doc As New MSHTML.HTMLDocument
    Dim e As MSHTML.HTMLGenericElement
    Dim currentRow As MSHTML.HTMLTableRow
    Dim currentCell As MSHTML.HTMLTableCell
    
    Do Until Web.Busy = False
        DoEvents
    Loop
    
    Web.Navigate2 "http://altavista.com/";
    
    Do Until Not Web.Busy
        DoEvents
    Loop
    
    Do While Web.Document.body Is Nothing
        DoEvents
    Loop
    
    Set Doc = Web.Document
    
    For Each e In Doc.All
        If e.tagName = "TABLE" Then
            For Each currentRow In e.rows
                List1.AddItem "Row: " & currentRow.outerHTML
                For Each currentCell In currentRow.cells
                    List1.AddItem "  Cell: " & currentCell.innerHTML
                Next
            Next
        End If
    Next
    
    Set currentCell = Nothing
    Set currentRow = Nothing
    Set e = Nothing
    Set Doc = Nothing
    Set Web = Nothing

Greg

-----Original Message-----
From: Rajput, Goutam [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 10, 2004 12:41 PM
To: [EMAIL PROTECTED]
Subject: [wdvltalk] Parse HTML using MSHTML in Visual Basic 6.0


Hi
I am trying to parse a HTML document using MSHTML in VB 6.0. Basically I
want to read <table> tags from the html and get the data(TR's and TD's)
inside the table tag. I have spend a entire day trying to figure out but no
success. I did zillion google search and I couldn't find a single sample Any
sample or a link to a tutorial/article is highly appreciated.

Thanks
G


The information in this electronic mail message is sender's business
Confidential and may be legally privileged.  It is intended solely for the
addressee(s).  Access to this Internet electronic mail message by anyone
else is unauthorized.  If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be taken
in reliance on it is prohibited and may be unlawful. 
The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message and
its attachments could have been infected during  transmission. By reading
the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. Galileo International is not liable for any loss or damage
arising in any way from this message or its attachments.



____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] 
       Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set 
WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.

Reply via email to