XML::LibXML で値を更新すると、最初の 2 行が削除されます。1 つの更新された値を除いて、xml をそのまま保持したい。
私の元のxmlは次のとおりです。
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>test.name</name>
<value>help</value>
<description>xml issue</description>
</property>
....
コードは次のとおりです。
my $parser =XML::LibXML->new();
my $tree =$parser->parse_file($file) or die $!;
my $root =$tree->getDocumentElement;
my $searchPath="/configuration/property[name=\"$name\"]/value/text()";
my ($val)=$root->findnodes($searchPath);
$val->setData($new_val);
open (UPDXML, "> $file") or die "ERROR: Failed to write into $file...";
print UPDXML $root->toString(1);
close (UPDXML);
print UPDXML $root->toStringC14N(1) を試しましたが、役に立ちません...