。。。所以在我用b
替换a
之后,以前对a
的所有引用现在都指向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;
输出:
<?xml version="1.0"?>
<r><p><n/></p></r>
<c/><c/>