I've been getting an error message for the following piece of code (I'm trying to get the content inside the 'article' tags on a certain web page):
function getTextFromLink($url) {
$html = new DOMDocument();
$html->loadHTML($url);
$text = $html->getElementsByTagName('article')->item(0)->textContent;
return $text;
}
It says that I'm trying to get the property of a non-object on the line with
$text = $html->getElementsbyTagName('article')->item(0)->textContent;
I'm fairly new to php and DOM; what am I missing here?