title: Checking if an object attribute is set - SimpleXML
body: <p>I have some XML I am using PHP's SimpleXML class with and I have elements within the XML such as:</p>
  
  <pre><code>&lt;condition id="1" name="New"&gt;&lt;/condition&gt;
  &lt;condition id="2" name="Used"&gt;&lt;/condition&gt;
  </code></pre>
  
  <p>However they are not always there, so I need to check if they exist first.</p>
  
  <p>I have tried..</p>
  
  <pre><code>if (is_object($bookInfo-&gt;page-&gt;offers-&gt;condition['used'])) {
      echo 'yes';
  }
  </code></pre>
  
  <p>as well as..</p>
  
  <pre><code>if (isset($bookInfo-&gt;page-&gt;offers-&gt;condition['used'])) {
      echo 'yes';
  }
  </code></pre>
  
  <p>But neither work. They only work if I remove the attribute part.</p>
  
  <p>So how can I check to see if an attribute is set as part of an object?</p>