php SimpleXMLElement 子结点插入SimpleXMLElement

$to_xml = simplexml_load_file("father.xml");
$from_xml = simplexml_load_file("son.xml");
sxml_append($to_xml , $from_xml );
var_dump($to_xml);
function sxml_append(SimpleXMLElement $to, SimpleXMLElement $from){    
    $to_dom = dom_import_simplexml($to);    
    $from_dom = dom_import_simplexml($from);    
    $to_dom->appendChild($to_dom->ownerDocument->importNode($from_dom, true));
}

你可能感兴趣的:(php SimpleXMLElement 子结点插入SimpleXMLElement)