Wizard
Wizard

Reputation: 11275

Simple HTML parser get link between td tag

HTML structure:

<tr>
<td><div class="img ico-networking" title="Tinklalapis"></div></td>
<td>Tinklalapis</td>
<td>
<a href="http://www.google.lt" target="_blank" rel="nofollow">http://www.servit.lt</a>                                                      <a title="Informacija apie svetainę servit.lt" href="http://www.ooo.lt/svetaine/google.lt" class="infoAboutSite iconInfo" target="_blank"></a>                                                                                              <a title="Įmonės svetainė servit.lt" href="google.com" class="infoAboutSite siteScreenshot iconWww" target="_blank"></a>                                            </td>
</tr>

My PHP selector: $tr->children[2]->find('a',0)->href;

I'm getting empty string, what is wrong with my selector ?

Upvotes: 0

Views: 385

Answers (1)

NaeN
NaeN

Reputation: 174

I think this code that helps you

<?php
$help1 = '<tr>
<td><div class="img ico-networking" title="Tinklalapis"></div></td>
<td>Tinklalapis</td>
<td>
<a href="http://www.google.lt" target="_blank" rel="nofollow">http://www.servit.lt</a>                                                      <a title="Informacija apie svetainę servit.lt" href="http://www.ooo.lt/svetaine/google.lt" class="infoAboutSite iconInfo" target="_blank"></a>                                                                                              <a title="Įmonės svetainė servit.lt" href="google.com" class="infoAboutSite siteScreenshot iconWww" target="_blank"></a>                                            </td>
</tr>';
include "simplehtmldom_1_5/simple_html_dom.php";
$help2 = str_get_html($help1);
echo $help2->find('a',0)->href ;

?>

Upvotes: 1

Related Questions