in reply to XML replace password with a specific tag
Here's one way with XML::LibXML:
use warnings; use strict; use XML::LibXML; my $doc = XML::LibXML->load_xml(location => 'foo.xml'); my @nodes = $doc->findnodes('//param[@name="SSLKeyStorePassword"]'); if (@nodes) { warn "found more than one SSLKeyStorePassword" if @nodes>1; $nodes[0]->{value} = 'BLABLA8'; } else { die "did not find SSLKeyStorePassword" } $doc->toFile('bar.xml', 1);
Whatever you do, do not use regular expresions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML replace password with a specific tag
by choroba (Cardinal) on Oct 14, 2022 at 08:10 UTC |