Skip to content

Instantly share code, notes, and snippets.

@matthewtrask
Created March 12, 2016 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewtrask/eaa75491b81f209d702f to your computer and use it in GitHub Desktop.
Save matthewtrask/eaa75491b81f209d702f to your computer and use it in GitHub Desktop.
<?php
$dst = simplexml_load_file( '35928_3210820_mp.xml' );
$dst = dom_import_simplexml( $dst )->ownerDocument;
$parent = $dst->getElementsByTagName( 'merchandiser' )->item(0);
$src = simplexml_load_file( '39153_3210820_mp.xml' );
foreach( $src->product as $product )
{
var_dump($src);
$node = dom_import_simplexml( $product );
$node = $dst->importNode( $node, 1 );
$parent->appendChild( $node );
}
$final = new DOMDocument();
$final->loadXML( $dst->saveXML(), LIBXML_NOBLANKS );
$final->formatOutput = True;
echo $final->saveXML();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment