Hello everyone,

I am trying to retrieve some info from a remote site using PHP DOMDocument and I cannot figure out why the code returns NULL, although the provided ID exists on the page. Please help.

$dom = new DOMDocument("1.0", "utf-8");
@$dom->loadHTMLFile('http://sports.yahoo.com/news/messis-tax-hearing-put-back-122033643--sow.html');
$content = $dom->getElementById('yog-content');
var_dump($content);

Recommended Answers

All 4 Replies

Thank you for reply. The result is still NULL and I do not get the error message, even if I have removed '@'. It's strange.

I think the unesaped & on that page is causing this. What you can try is to replace them before loading.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.