I am crawling a web with the help of simple dom in PHP.
I am getting following html with the help curl:
<ul><li>1</li><li>2</li><li>3</li><li><a href="http:abc.com">4</a></li></ul>
Now, I need to href (link) of anchor tag which is in the last li of this ul with the help of simple dom object. Please provide me syntax how can I do this?
I have tried with the following code but i am not able to find the last li…
require_once 'simple_html_dom.php';
$html = "<ul><li>1</li><li>2</li><li>3</li><li><a href="http:abc.com">4</a></li></ul>";
$oDocumentModel = new simple_html_dom();
$oDocumentModel->load($html);
$ul = $oDocumentModel->find('ul',0);
You can loop through the li and convert it in array and find the last element. if you have smaller set of li like…
Or you can use lastChild() just go through the http://simplehtmldom.sourceforge.net/manual_api.htm