fold_array_by_name (XmlSimple)

    # File lib/xmlsimple.rb, line 594
      def fold_array_by_name(name, array)
        return array unless @options['keyattr'].has_key?(name)
        key, flag = @options['keyattr'][name]

        hash = Hash.new
        array.each { |x|
          if x.instance_of?(Hash) && x.has_key?(key)
            value = x[key]
            return array if value.instance_of?(Hash) || value.instance_of?(Array)
            value = normalise_space(value) if @options['normalisespace'] == 1
            hash[value] = x
            hash[value]["-#{key}"] = hash[value][key] if flag == '-'
            hash[value].delete(key) unless flag == '+'
          else
            $stderr.puts("Warning: <#{name}> element has no '#{key}' attribute.")
            return array
          end
        }
        hash = collapse_content(hash) if @options['collapseagain']
        hash
      end