#!/usr/bin/perl use warnings; use strict; use XML::LibXML; my $xml = 'XML::LibXML'->load_xml( string => << '======' ); <root> <parameters> <key name="Repetitions" value="500" /> <key name="Mode" value="COLD" /> </parameters> </root> ====== my $root = $xml->documentElement; my ($value) = $root->findnodes('parameters/key/@value[.="500"]'); $value->setValue(501); print $root->serialize;
Or, if you find it too verbose, here is the same in XML::XSH2:
open file.xml ; set /root/parameters/key/@value[.="500"] 501 ; save :b ;
In reply to Re: Modifying XML with LibXML
by choroba
in thread Modifying XML with LibXML
by jasal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |