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");
$content = $dom->getElementById('yog-content');

Recommended Answers

If I run this code I get an error message (which you are hiding with the @): DOMDocument::loadHTMLFile(): htmlParseEntityRef: expecting ';' in http://sports.yahoo.com/news/messis-tax-hearing-put-back-122033643--sow.html, line: 539 meaning the DOM could not be parsed correctly. …

Jump to Post

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, learning, and sharing knowledge.