How can I move XML elements with PHP's SimpleXML?
问题 How can I move an xml element elsewhere in a document? So I have this: <outer> <foo> <child name="a"/> <child name="b"/> <child name="c"/> </foo> <bar /> </outer> and want to end up with: <outer> <foo /> <bar> <child name="a"/> <child name="b"/> <child name="c"/> </bar> </outer> Using PHP's simpleXML. Is there a function I'm missing (appendChild-like)? 回答1: You could make a recusrive function that clones the attributes and children. There is no other way to move the children with SimpleXML