simplexml
How can I check if a object is an instance of a specific class?
You can check if an object is an instance of a class with instanceof, e.g. if($role instanceof SimpleXMLElement) { //do stuff }
Format output of $SimpleXML->asXML(); [duplicate]
There’s a variety of solutions in the comments on the PHP manual page for SimpleXMLElement. Not very efficient, but certainly terse, is a solution by Anonymous $dom = dom_import_simplexml($simpleXml)->ownerDocument; $dom->formatOutput = true; echo $dom->saveXML(); The PHP manual page comments are often good sources for common needs, as long as you filter out the patently wrong … Read more