There’s a large rebellion over XML config files from programmers who don’t like to type XML and don’t want to learn APIs for processing it. They’d rather limp along with the same
scanf code they’ve been using for the last 20 years.
The problem is there really isn’t such a thing as a plain text config file. What there is are specially formatted text files that are easily as complex as the XML equivalent but inconsistent, poorly documented, and easily broken. For instance, consider this extract from LogValidator’s “plain text” config file:
## MailFrom : From: address for e-mail output ## ## ## Unless the relevant option is specified when running the LogValidator, ## the mail output will use ServerAdmin (see above) as From: and To: ## This option allows you to override the From: parameter ## DEFAULT = ServerAdmin # MailFrom: email@example.com ## Title : a more useful Subject: for the Mail output and <title> for HTML Output ## ## ## Tell the mail/HTML output what this config is all about ## and make them use a better subject than the vanilla "LogValidator results" ## DEFAULT = Logvalidator results # Title = Logvalidator results ## [apache] DocumentRoot : where the files are located ## ## ## For some log formats, it is necessary to know where the actual files ## reside on the server DocumentRoot /var/www/
In particular look at the three fields and their format. In the space of three items, we have
Name: Value Name = Value Name Value
This is inconsistent and confusing and seems likely to lead to bugs. Perhaps LogValidator should pick one syntax and stick to it? Better yet, just make this all XML. This really is a classic example of why plain text is not simpler than XML.
This is of course just one format for one Perl program. The next program will be a little different still. You’ll have to write a custom parser to handle it, learn a new syntax to write it, and then remember which one you’re using when. With XML all your fields are clearly delimited by tags, so the boundaries are obvious. With XML, you get to use the same parser every time.
XML may not be simpler for any one config format. XML is, however, much simpler for all config formats.