I am working with simple web crawler. Below is simple html code i used to learn.
input.php
<ul id="nav">
<li>
<a href="www.google.com">Google</a>
<ul>
<li>
<a href="mail.gmail.com">Gmail</a>
</li>
</ul>
</li>
<li>
<a href="www.yahoo.com">Yahoo</a>
<ul>
<li>
<a href="mail.yahoo.com">Yahoo Mail</a>
</li>
</ul>
</li>
</ul>
I need to crawl the first anchor tag in ul[id=nav]->li
. The code i used to crawl input.php is
<?php
include 'simple_html_dom.php';
$html = file_get_html('input.php');
foreach ($html->find('ul[id=nav]') as $navUL){
foreach ($navUL->find('li') as $navUL_LI){
echo $navUL_LI->find('a',0)->outertext."<br>";
}
}
?>
It Displays all the anchor tag in my input.php. I need to display only google and yahoo. How can i achieve this?