none
Parse from HTML to Access RRS feed

  • Question

  • Hi, I found and adjusted some code (VBA) to parse an HTML file into an access table. It is working fine but the HTML has some information which is enclosed in <div> and therefore not part of the HTML table which I need to store in my access table. This is the code I have:

     Dim html As HTMLDocument
    'open Internet Explorer in memory, and go to website
    Set ie = New InternetExplorer
    ie.Visible = True
    ie.Navigate "file:///C:/temp/tempTable.html"
    'show text of HTML document returned
    Set html = ie.Document
    'close down IE and reset status bar
    Set ie = Nothing
    'Application.StatusBar = ""
    Dim QuestionList As IHTMLElement
    Set QuestionList = html.getElementsByName("reservation-info")
     
     
     
    Me.Text3.Value = QuestionList
    Me.Requery
    Me.Refresh
     
     
        ' Delete the temp file
        'Kill tempFile
        DoCmd.OpenTable ("T_SQLTYPES")
    End Sub

    All I want for now is to display an item enclosed in <div> in my HTML on Text3 textbox in my form -or better still include it in my table T_SQLTYPES. Here is my HTML code:

        <div class=""reservation-info"">
                Name of Hotel · #603439460
            </div>
         
        </div> <!-- /span12 -->
         
        </div> <!-- /row -->
         
         
         
         
        <div class=""row-fluid"">
         
        <div class=""span6"">
         
        <table class=""table table-condensed table-striped table-hover table-bordered table-darkheader"">
         
            <tr>
                <th colspan=""3"" class=""booking-room"">Room 1</th>
            </tr>
         
         
         
            <tr>
                <td><b>Guest name</b></td>
                <td>
                    <strong>
                        Mr XXX
                    </strong>
                </td>
            </tr>
            <tr><td>Checkin</td><td>14-05-2014</td></tr>
            <tr><td>Checkout</td><td>25-05-2014</td></tr>
         
            <tr>
                <td>Room type</td>
                <td>
                    Double or Twin Room - Single Use
                </td>
            </tr>
         
            <tr>
                <td>Number of persons</td>
                <td>
                    1 
                </td>
            </tr>
         
         
         
         
        <tr>
            <td>Arrival</td>
            <td>
         
                Wednesday, May 14, 2014
         
            </td>
        </tr>
        <tr>
            <td>Departure</td>
            <td>
         
                Sunday, May 25, 2014
         
            </td>
        </tr>
         
         
         
         
         
         
            <tr>
                <td>Number of nights</td>
                <td>
                    11
                </td>
            </tr>
         
            <tr>
                <td>
                    Total costs
                    (based on Single Use)
                </td>
                <td>
                    EUR 206.8
         
         
         
                    <br>7 % VAT is included.
         
         
                </td>
            </tr>
         
            <tr>
                <td>Costs per night</td>
                <td>
                18.80
                </td>
            </tr>
         
         
            <tr>
                <td>Costs per night for more than 1 person</td>
                <td>
         
                </td>
            </tr>
         
         
            <tr>
                <td>Status</td>
                <td>
                    ok
         
                </td>
            </tr>
         
            <tr>
                <td>Smoking preference</td>
                <td>
                    non-smoking
                </td>
            </tr>
         
         
         
         
         
            <tr>
        <td>Applicable Cancellation Policy</td>
        <td>
         
         
        If cancelled or modified up to 3 days before date of arrival,  no fee will be charged.<br />
         
        If cancelled or modified later or in case of no-show, 100 percent of the total price of the reservation will be charged.<br />
         
         
        </td>
        </tr>
         
            <tr>
        <td>Applicable Deposit Policy</td>
        <td>
         
         
        The total price of the reservation will be charged at least 2 days prior to arrival.<br />
         
         
        </td>
        </tr>
         
         
         
            <tr>
            <td>Applicable Meal Plan</td>
            <td>Breakfast is included in the room rate.</td>
        </tr>
         
         
        </table>
         
    
    
    I would like <div class=""reservation-info"">
    Name of Hotel · #603439460
    </div> to be displayed either on my form Text3 or better still included in the table I am importing into Access. Any help would be appreciated. Thanks

    Saturday, May 31, 2014 7:14 PM