cyanat
cyanat

Reputation: 117

PHP DOMDocument: Get Null if no nodeValue

Here is my php:

$drmMediaId=$drmNode->getElementsByTagName("media_id")->item(0)->firstChild->nodeValue;

And here is my drmNode

<drm>
    <type>no_media</type>
    <media_id></media_id>
</drm>

In that case, I get a "Trying to get property of non-object".

I would like a NULL in my $drmMediaId. Do I have to test existence of nodeValue each time for that?

Thanks!

Upvotes: 1

Views: 306

Answers (0)

Related Questions