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 <<< | |
| Views: 410 | |
| Total comments: 0 | |