I have some XML. I use the PHP SimpleXML class, and I have elements in XML, such as:
<condition id="1" name="New"></condition> <condition id="2" name="Used"></condition>
However, they do not always exist, so I need to check if they exist in the first place.
I tried..
if (is_object($bookInfo->page->offers->condition['used'])) { echo 'yes'; }
and..
if (isset($bookInfo->page->offers->condition['used'])) { echo 'yes'; }
But no one is working. They only work if I delete the attribute part.
So how can I check if an attribute is set as part of an object?
source share