Quantcast
Channel: How can I merge XML files? - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Answer by LanDenLabs for How can I merge XML files?

$
0
0

reposting answer from https://www.perlmonks.org/?node_id=127848

Paste following into a perl script

use strict;require 5.000;use Data::Dumper;use XML::Simple;use Hash::Merge;my $xmlFile1 = shift || die "XmlFile1\n";my $xmlFile2 = shift || die "XmlFile2\n";my %config1 = %{XMLin ($xmlFile1)};my %config2 = %{XMLin ($xmlFile2)};my $merger = Hash::Merge->new ('RIGHT_PRECEDENT');my %newhash = %{ $merger->merge (\%config1, \%config2) };# XMLout (\%newhash, outputfile => "newfile", xmldecl => 1, rootname => 'config');print XMLout (\%newhash);

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>