Reputation: 57
I have following code but even if node value is empty or populated I get same echo = is not set or empty
In my header I include XML file which include :
$linkwebsite = $element->getElementsByTagName('linkwebsite')->item(0) ;
PHP Code:
<?php
if (!empty($linkwebsite)){
echo 'not empty';
}
else{
echo 'is not set or empty';
}
?>
Upvotes: 0
Views: 871
Reputation: 57
Ok got it when I echo variable got error - Object of class DOMElement could not be converted to string so I had to set variable node value as follow
<?php
if (!empty($linkwebsite->nodeValue)){
echo 'not empty';
}
else{
echo 'is not set or empty';
}
?>
Upvotes: 0