use XML::LibXML; use warnings; use strict; my $copy = ''; my $lastnode = ''; my $file = (); #UPDATE my $d = XML::LibXML->new->parse_file(join "", $file); © &paste; $d->toFile('c:\test1.xml'); sub copy { for my $dead ($d->findnodes(q{/category/subcategory/product[product_id = "800.55.01"]})) { #copy the node before it die $copy = $dead->cloneNode; #the node die $dead->unbindNode; } } sub paste { for my $paste ($d->findnodes(q{/category/subcategory[@name = "Grand Arabica"]})) { my $curcopy = $copy; $lastnode = $paste->lastChild; $paste->insertAfter($lastnode, $curcopy); } } __DATA__ Prestige is a very traditional French recipe: a blend of Robusta and Arabica beans. The Robusta is known for its strength and the Arabica for its delicate flavour. The Prestige is the ideal coffee for Espresso. The 500gr come in the re-usable Aroma Box especially designed to preserve the freshness and aroma of your coffee. images/prestige.jpg Coffee D A 800.55.01 Legal Legal Prestige 250 12 /recipes/coffee1.html Coffee D A 801.55.01 Legal Legal Prestige Boite Arôme 500 6 Experience the subtle voluptuousness of extraordinary Arabica coffee in your cup. Grand Arabica: incomparable pleasure in coffee. images/arabica.jpg Coffee A D S 802.55.01 Legal Grand Arabica 250 12