Checking if an object attribute is set - SimpleXML

msapola

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