I have two pages that Im trying to extract the title tag from using an Xpath query. This page works: http://www.hobbyfarms.com/farm-directory/category-home-and-barn-resources-1.aspx
This page doesn't: http://cattletoday.com/links/Barns_and_Metal_Buildings/page-1.html?s=A
Here's my code:
$dom = new DOMDocument();
@$dom->loadHTMLFile($href);
$xpath = new DOMXPath($dom);
$titleNode = $xpath->query("//title");
foreach ($titleNode as $n) {
$pageTitle = $n->nodeValue;
}
I've also tried this:
$xpath->query('//title')->item(0)->textContent
But it doesnt work for the one URL either.
Does anyone see why this is occurring? And hopefully have a solution.