PHP.nl

Dom\import_simplexml

Dom\import_simplexml

Gets a Dom\Attr or Dom\Element object from a SimpleXMLElement object

 **Dom\import_simplexml** object $node

This function takes the given attribute or element (a instance) and creates a or node, respectively. The new refers to the same underlying XML node as the . node``SimpleXMLElement``Dom\Attr``Dom\Element``Dom\Node``SimpleXMLElement

The or . Dom\Attr``Dom\Element

Voorbeeld: Import SimpleXML into DOM and modify SimpleXML through DOM

Error handling omitted for brevity.

<?php

$sxe = simplexml_load_string('<books><book><title>blah</title></book></books>');
$elt = Dom\import_simplexml($sxe);
$elt->setAttribute("foo", "bar");
echo $sxe->asXML();

?>
<?xml version="1.0"?>
<books foo="bar"><book><title>blah</title></book></books>

simplexml_import_dom