I'm trying to do some XML transformation using XML:

OM, and while I've figure out how to create source/target XML:

OM [document] objects; get a handle on the root node for each document; and get node information from the source document -- I'm having problems figuring out how to create new nodes in the new document. I have a feeling it's something "simple" that I'm missing - but...well...I'm missing it.
Here's some [simplified] sample code demonstrating my sitation:
- Original structure: <record>
<name>
<last>...</last>
<first>...</first>
</name>
<address_info>
<address_line1>...</address_line1>
<address_line2>...</address_line2>
<city>...</city>
<state>...</state>
<zip>...</zip>
</address_info>
</record> - New Structure: <users>
<user>
<last>...</last>
<first>...</first>
<address>
<address_line1>...</address_line1>
<address_line2>...</address_line2>
<city>...</city>
<state>...</state>
<zip>...</zip>
</address>
</user>
</users> - Sample / Simplified Code: ...
use TeamSite:
CRnode;
use XML:
OM;
...
my $old_root = q{}
eval{ $old_root = TeamSite:
CRnode->new(read_file($infile)); };
handle_error($@) if ($@);
my $old_xml = $old_root->get_xml(); # transform "iwov" to "xml" format shown above
my $old_root_elem = 'record';
my $old_dom = XML:
OM:
arser->new();
my $old_doc = q{};
eval{ $old_doc = $old_dom->parse($old_xml); };
handle_error($@) if ($@);
my $new_xml = qq[<users></users>];
my $new_root_elem = 'users';
my $new_dom = XML:
OM:
arser->new();
my $new_doc = q{}
eval { $new_doc = new_dom->parse($new_xml); };
handle_error($@) if ($@);
my $old_rootnode = ($old_doc->getElementsByTagName($old_root_elem))[0];
my $new_rootnode = ($new_doc->getElementsByTagName($new_root_elem))[0];
# so far, I believe all is okay
my $old_nodes = $old_rootnode->getChildNodes();
foreach my $node (@$nodes){
my $old_xpath = $old_rootnode.'.'.$node->getNodeName;
my $new_xpath = map_xpath($old_xpath);
# e.g.:
# old_xpath => record.name
# new_xpath => users.user
#=# (Q)
}
...
Q: How do I create a new node ('user') as a child node of the new document / new root node ('users')?
If I clone the existing node from the source doc and try to add it with:
$new_rootnode->insertBefore($cloned_node, undef);
I get an error about the cloned node having a different source document
I don't see any method for creating a new node in any of the XML:

OM::* perldoc's I've looked at - did I miss one?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com