# Copyright 1999-2016. Parallels IP Holdings GmbH. All Rights Reserved.
package MiscConfigParser;

use strict;
eval{require warnings;1;};
use Logging;

sub parseApsIndexFile {
  my ( $file ) = @_;

  my %xmlHash;
  my $name;
  if ( open( FILE, $file ) ) {
    while (<FILE>) {
      chomp;
      if ( $_ =~ /<([A-Za-z\-]*)\s+name=\"(.*)\">/ ) {
        $name = $2;
      }
      elsif ( $_ =~ /<([A-Za-z\-]*)>(.*)<\/([A-Za-z\-]*)>/ ) {
        push @{ $xmlHash{$name} }, $2 unless $1 eq "valid";
      }
    }
    close FILE;
  }
  else {
    Logging::debug( "Aps index file " . $file . " is not exists. Skipping.");
  }
  return %xmlHash;
}