1

I want to extract value of 3rd td where 1st td has value 'Total (A)+(B)+(C)'

                    <td class="tbmain" height="25"><b>Total (A)+(B)+(C)</b></td>

                    <td class="tbmain" align="right"><b>100,000</b></td>     

                    <td class="tbmain" align="right"><b>111,111,111</b></td>

                    <td class="tbmain" align="right"><b>101,101</b></td>

                </tr>
Crimsonarcher
  • 115
  • 1
  • 6
  • 10
  • 1
    Please consider not to use regular exressions to parse HTML (see [here](http://stackoverflow.com/a/1732454/577423)). – Howard Dec 11 '11 at 12:20
  • I'm using VBA to parse and HTML page that i'm receiving. Whats the best way then to parse if not regex? I can't uniquely identify the field via id either! – Crimsonarcher Dec 11 '11 at 13:36

1 Answers1

1

You can do this easily with jQuery:

alert($("table tr td:contains('Total (A)+(B)+(C)')").siblings("td:eq(1)").html());

will return <b>111,111,111</b> adn this is the value of the 3rd td where the 1st td has Total (A)+(B)+(C) in the value

Example

You can do this too when you get the table as string (example)

But if you relay want do do this with regex, this can help:

<tr>(\s+)?<td.*?>(.*?)?</td>(\s+)?<td.*?>.*?</td>(\s+)?<td.*?>(.*?)</td>
noob
  • 8,982
  • 4
  • 37
  • 65