#!/usr/bin/perl
my $file = "/etc/libvirt/qemu/NAS.xml";
my %vmconfhash;
use XML::Mini::Document;
use XML::Mini;
use Data::Dumper;
open(FILE, "<$file") || die "Error: File not readable.\n";
my @lines = <FILE>;
close(FILE);
my $XMLString = join(' ',@lines);
my $xmlDoc = XML::Mini::Document->new();
eval {
$xmlDoc->parse($XMLString);
};
if ($@) {
print "Error: XML parsing error: $@\n";
exit(1);
}
#my $xmlRoot = $xmlDoc->getRoot();
my $hash = $xmlDoc->toHash();
print Dumper($hash);
my $options = {
'attributes' => {
'domain' => 'type',
'type' => ['arch','machine'],
'boot' => 'dev',
'clock' => 'offset',
'disk' => ['device','type'],
'source' => 'dev',
'target' => ['dev','bus'],
'readonly' => '',
'interface' => 'type'
}
};
$xmlDoc->fromHash($hash, $options);
print $xmlDoc->toString();