#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0

    Parsing data from HTML Table


    Hi all,

    Cant seem to find a definitive answer on this one so hope someone can help...

    I am wanting to parse data from the following html table:

    <table border='1' class='workers'>
    <tr><th>Login</th><th>Password</th>
    <th>Found blocks</th>

    <th>Current shares</th>
    <th>Score</th>

    <th>Last share at</th>
    <th>Mhash/s<small>*</small></th>
    <!--<th>LP</th>-->
    <th>Actions</th></tr>



    <tr>
    <td>answer1</td>
    <td>answer2</td>
    <td>0answer3</td>

    <td>answer4</td>
    <td>answer5</td>

    <td>answer6</td>
    <td>answer7</td>
    <!--<td>
    on
    </td>-->
    <td>

    I have parsed data from other parts of the website which was OK for me as they were forms and I used webbrowser1.document.getelementbyid etc but struggling to understand this one. I know I should try myself but don't know where to start as I'm a bit of a noob. Basically I need to parse "answer1" through "answer7". If someone could recommend a tutorial I would be happy to try myself but I can't seem to find one for this!?!?

    Thanks in advance, Jibber
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    45
    There is nothing special about HTML coding. It is very similar to XML. Tags are defined between angle brackets, and the data is defined between pairs of tags. A browser reads from one end to the other and follows the directions provided by the tags. For the table:
    tr - Table Row
    th - Table Header
    td - Table Definition
    It can be written as:
    Code:
    <table border='1' class='workers'><tr><th>Login</th><th>Password</th><th>Found blocks</th><th>Current shares</th><th>Score</th><th>Last share at</th><th>Mhash/s<small>*</small></th><!--<th>LP</th>--><th>Actions</th></tr><tr><td>answer1</td><td>answer2</td><td>answer3</td><td>answer4</td><td>answer5</td><td>answer6</td><td>answer7</td><!--<td>on</td>--><tr></Table>
    for compactness or:
    Code:
    <table border='1' class='workers'>
        <tr>
            <th>
                Login
            </th>
            <th>
                Password
            </th>
            <th>
                Found blocks
            </th>
            <th>
                Current shares
            </th>
            <th>
                Score
            </th>
            <th>
                Last share at
            </th>
            <th>
                Mhash/s
                <small>
                    *
                </small>
            </th>
            <!--<th>
                LP
            </th>-->
            <th>
                Actions
            </th>
        </tr>
        
        <tr>
            <td>
                answer1
            </td>
            <td>
            answer2
            </td>
            <td>
                answer3
            </td>
            <td>
                answer4
            </td>
            <td>
                answer5
            </td>
            <td>
                answer6
            </td>
            <td>
                answer7
            </td>
            <!--
            <td>
                on
            </td>
            -->
        <tr>
    </Table>
    for readability.

    Simply search through the string with a pair of pointers and save the data between the tag pairs of interest.

    J.A. Coutts

IMN logo majestic logo threadwatch logo seochat tools logo