1--TEST-- 2SimpleXML: clone 3--SKIPIF-- 4<?php if (!extension_loaded("simplexml")) print "skip"; ?> 5--FILE-- 6<?php 7 8$xml =<<<EOF 9<?xml version='1.0'?> 10<!DOCTYPE sxe SYSTEM "notfound.dtd"> 11<sxe id="elem1"> 12 <elem1 attr1='first'> 13 <!-- comment --> 14 <elem2> 15 <elem3> 16 <elem4> 17 <?test processing instruction ?> 18 </elem4> 19 </elem3> 20 </elem2> 21 </elem1> 22</sxe> 23EOF; 24 25$sxe = simplexml_load_string($xml); 26 27$copy = clone $sxe; 28 29var_dump($copy); 30 31?> 32===DONE=== 33--EXPECTF-- 34object(SimpleXMLElement)#%d (2) { 35 ["@attributes"]=> 36 array(1) { 37 ["id"]=> 38 string(5) "elem1" 39 } 40 ["elem1"]=> 41 object(SimpleXMLElement)#%d (3) { 42 ["@attributes"]=> 43 array(1) { 44 ["attr1"]=> 45 string(5) "first" 46 } 47 ["comment"]=> 48 object(SimpleXMLElement)#%d (0) { 49 } 50 ["elem2"]=> 51 object(SimpleXMLElement)#%d (1) { 52 ["elem3"]=> 53 object(SimpleXMLElement)#%d (1) { 54 ["elem4"]=> 55 object(SimpleXMLElement)#%d (1) { 56 ["test"]=> 57 object(SimpleXMLElement)#%d (0) { 58 } 59 } 60 } 61 } 62 } 63} 64===DONE=== 65