Take a node of a DOM document and make it into a SimpleXML node in PHP

Description

The following code shows how to take a node of a DOM document and make it into a SimpleXML node.

Example


/* w w w  .  ja  va 2 s.com*/
<?php
    $dom=new domDocument;
    $dom->loadXML("<note><to>Work</to><from>Home</from></note>");
    $x=simplexml_import_dom($dom);
    echo $x->from;
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    XML »




DOM
SimpleXML
SimpleXMLElement
XML Parser