From: James Edward Gray II Date: 2007-10-03T08:00:33+09:00 Subject: Re: Config files On Oct 1, 2007, at 6:21 PM, Lee Jarvis wrote: > I am writing an application that will read and grab values from a > configuration file. I am wondering what peoples opinions are on > what to > use. YAML? XML? Does anyone have any preference? Are any better > then the > others or is it just down to user preference? YAML tends to work out well, when it's very simple data fields being collected. That said, YAML's syntax rules are quite complex and asking a user to edit any non-trivial data in the format is a bad idea, in my opinion. If you need markup at all, use XML. It's a markup language, after all. YAML is not. Also, while more verbose, XML has a much easier syntax that far more people are familiar with. I'm not saying that means you have to use it, but it's something to stay aware of. Finally, I've used this trick a couple of times now and I just love it: #!/usr/bin/env ruby -wKU require "ostruct" module Config module_function def load_config_file(path) eval <<-END_CONFIG config = OpenStruct.new #{File.read(path)} config END_CONFIG end end __END__ That let's me do my configurations in pure Ruby, which may or may not be appropriate for your needs. I guess the most important thing is to consider your audience. James Edward Gray II