Reputation: 295
I am using Zend Dom component to parse some Html blocks, but i have problems extracting the a,b,c,d,e,f data from the following block:
<div id="center">
<form action="" method="get">
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</form>
<table>
<tr>
<td align="center"><b>a</b></td>
<td align="left"><b>b</b>
<br />c
<br />d
</td>
<td align="left"><b>e<br />
f<br />
g
</b>
</td>
</tr> <!-- this block repeats 10 times with other values instead of a,b,c...-->
</table>
</div>
Code:
$client = new Zend_Http_Client();
$client->setUri('http://example.com');
$response = $client->request();
$html = $response->getBody(); // the Html is the example above
$dom = new Zend_Dom_Query($html);
$results = $dom->query('#center table tr td');
Upvotes: 0
Views: 4348
Reputation: 16035
Is that what you're looking for?
$dom = new Zend_Dom_Query ($code);
$results = $dom->query ('#center table tr td');
foreach ($results as $r)
{
echo '<p>', $r->textContent, '</p>';
}
Upvotes: 2