DOM Interoperability

With both the DOM and SimpleXML extensions being tree parsers, this allows for a certain degree of interoperability between the two. This can be handy if you prefer one over the other when refactoring legacy code or if you have use cases for both within a single application.

<?php
// Converts a SimpleXMLElement to a DOMElement
$domElement = dom_import_simplexml($simpleXmlElement);

// Converts a DOMNode to a SimpleXMLElement
$simpleXmlElement = simplexml_import_dom($domNode);
?>

© SimpleXML Extension — Web Scraping

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