... so after I replace a
with b
, all previous references to a
now point to b
?
#!/usr/bin/perl
use warnings;
use strict;
use XML::LibXML;
my $dom = 'XML::LibXML'->load_xml(string => '<r><p><c/></p></r>');
my ($n1) = $dom->findnodes('/r/p/c');
my ($n2) = $dom->findnodes('/r/p/c');
$n1->replaceNode('XML::LibXML::Element'->new('n'));
print $dom;
print $n1, $n2;
Output:
<?xml version="1.0"?>
<r><p><n/></p></r>
<c/><c/>