SimpleXMLElement simplexml_import_dom ( DOMNode $node [, string $class_name = "SimpleXMLElement" ] )
Get a SimpleXMLElement object from a DOM node.
This function takes a node of a DOM document and makes it into a SimpleXML node. This new object can then be used as a native SimpleXML element.
Something that surprised me, any changes made to the SimpleXML object obtained from the imported DOMDocument also change the original DOMDocument.
$string = ''; abc
$domxml = DOMDocument::loadXML($string);
$simplexml = simplexml_import_dom($domxml);
$simplexml->foo = "xyz";
$simplexml->bar = "123";
echo $domxml->saveXML();
0 Comment:
Post a Comment