Comparing Nodes

To compare an element or attribute with a string value, you must first explicitly cast it to a string. Otherwise, it will be treated as an object, which may causes type issues including emitting errors.

<?php
if ((string) $sxe->body->ul['id'] == 'thelist') {
echo htmlentities((string) $sxe->body->ul['id']);
}
?>

© SimpleXML Extension — Web Scraping

>>> Back to TABLE OF CONTENTS <<<
Category: Article | Added by: Marsipan (03.09.2014)
Views: 366 | Rating: 0.0/0
Total comments: 0
avatar