Our unique script utilizes dom to extract all the links (a tags) from a document and then iterates through child nodes to collect information. The process starts like this:
@$dom->loadHTML($str);
$documentLinks = $dom->getElementsByTagName("a");
Here is a snippet of the loop in action:
$this->count]['href'] = strip_tags($documentLink->getAttribute('href'));
Now, my next task is to fetch the title tag from each page that we are looping through. My initial approach was:
$documentTitle = $dom->getElementsByTagName("title");
$documentLinks = $dom->getElementsByTagName("a");
However, when I tried including this in the loop/array to capture the document titles, it returned "[title] => DOMNodeList Object()". How can I incorporate fetching the title tag within the loop that works on a tags/child nodes?
$this->count]['title'] = $documentTitle;