#!/usr/bin/env perl

use strict;
use warnings;

use XML::LibXML;

my $parser = XML::LibXML->new();
my $doc = $parser->parse_string(<<'EOXML');
<?xml version="1.0" encoding="UTF-8"?>
<root-element>
	<settings/>
</root-element>
EOXML

my $doc2 = XML::LibXML::Document->new('1.0', 'UTF-8');
my $new_node = $doc2->createElement('root');
$doc2->setDocumentElement($new_node);

my $node = get_node($doc);
#$doc2->adoptNode($node);
$node->replaceNode($new_node);

my $str = $doc->toString();

sub get_node {
	my ($doc) = @_;

	my ($parent) = $doc->documentElement()->findnodes('settings');
	my $node = $parent->ownerDocument()->createElement('my-settings');
	$parent->appendChild($node);

	return $node;
}

1;
