草庐IT

php - DOMElement 克隆和追加 : 'Wrong Document Error'

对于使用PHP的DOMapi进行节点克隆,我有一些不完全理解的地方。这是一个示例文件,可以快速复制我遇到的问题。$doc=newDOMDocument('1.0','UTF-8');$root=$doc->createElement('root');//Thisdoesn'tworkeither$root=newDOMElement('root');$doc->appendChild($root);$doc2=newDOMDocument('1.0','UTF-8');$root2=$doc2->createElement('root2');$doc2->appendChild($ro