When I update a value using XML :: LibXML, the first two lines are deleted. I want to keep xml as is, except for one updated value.
My original 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>
....
And the code:
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);
I tried with UPDXML printing $ root-> toStringC14N (1), but that does not help ...
source share