I use this code to get all the link in a html page and it worked fine.
<?php
$html = file_get_contents('http://realestate.com.kh/real-estate-for-sale-in/all/');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.'<br />';
}
?>
But I want to get only specific link from div or class just like this
<ul class="menu">
<li><a href="#">product1</li>
<li><a href="#">product2</li>
<li><a href="#">product3</li>
<li><a href="#">product4</li>
</ul>
So how can I give the class to the above code so that I can get only link in menu class.
Thank you so much for help me solve this.