title: Check if xml node exists in PHP
body: <p>I have this simplexml result object:</p>
  
  <pre><code> object(SimpleXMLElement)#207 (2) {
    ["@attributes"]=&gt;
    array(1) {
     ["version"]=&gt;
     string(1) "1"
    }
    ["weather"]=&gt;
    object(SimpleXMLElement)#206 (2) {
     ["@attributes"]=&gt;
     array(1) {
     ["section"]=&gt;
     string(1) "0"
    }
    ["problem_cause"]=&gt;
    object(SimpleXMLElement)#94 (1) {
     ["@attributes"]=&gt;
     array(1) {
     ["data"]=&gt;
     string(0) ""
     }
    }
    }
   }
  </code></pre>
  
  <p>I need to check if the node "problem_cause" exists. Even if it is empty, the result is an error.
  On the php manual, I found this php code that I modified for my needs:</p>
  
  <pre><code> function xml_child_exists($xml, $childpath)
   {
      $result = $xml-&gt;xpath($childpath);
      if (count($result)) {
          return true;
      } else {
          return false;
      }
   }
  
   if(xml_child_exists($xml, 'THE_PATH')) //error
   {
    return false;
   }
   return $xml;
  </code></pre>
  
  <p>I have no idea what to put in place of the xpath query 'THE_PATH' to check if the node exists.
  Or is it better to convert the simplexml object to dom?</p>