need only the tags which are at the first level

S

Shanmu Gam

require 'rubygems'
require 'hpricot'

elements = Hpricot("<table>
<tr>
<td>...stuff I don't want...</td>
</tr>
<tr>
<td>
<table>
------------rows i want
<tr>
<td>Field 0
<table>
<tr>
<td>Field 1</td>
<td>Field 2</td>
</tr>
</table>
</td>
<td>Field 3</td>
<td>Field 4, Field 5</td>
</tr>
------------end of rows i want
</table>
</td>
</tr>
</table>")

from this above code, in second table, i need only the first level of
<td> values and i dont need the second level <td> tags which says "Field
1 Field 2" , i mean the output should be "Field 0 Field 3 Field 4" . i
tried but i got all <td> values
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top