Jump to content

Checking if a node exists


Arkane

Recommended Posts

Hey,

 

I've made a script to get data from another page which uses DOMDocument.  It works, but only if all of the tags exist.

 

For instance, I use

$var = $dom->getElementById('ctl00_mainContent_identityStrip_lblRank')->nodeValue;

The problem is, that the page I'm taking it from doesn't always have the element with that id.  I'm checking for multiple on the page, but some are there and some arent, but the script breaks if they aren't all there.  How can I check if the node exists, and then only create the variable if it does?

Link to comment
https://forums.phpfreaks.com/topic/176425-checking-if-a-node-exists/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.