I have a few applications which store their config files in XML format. For a regular application, using a text based config, I could update a value easily enough by using perl, or sed, or awk, or any one of a million tools. I'm looking for something similar for XML, which will allow me to easily and reliably perform operations like: update a value, add a node, or remove one.
Regular text parsing would seem to be too risky, as I have no real guarantees about the physical file format.
XML parsing in MS Powershell is easier than any parsing mechanism I've seen in any other language or environment I've personally encountered.
Given some XML file (test.xml):
You can easily access, modify and append nodes, values and attributes of the XML file from inside Powershell.
Resulting XML in file testNew.xml:
Incredibly easy! Enjoy.
Powershell is Microsoft's new shell that ships with Windows Server 2008 and Windows 7 and is a free download for XP/Vista/Server 2003 (perhaps others).
Some useful links:
Generating XML from other sources
Adding elements to XML:
Sample 1, MSDN PowerShell blog
Sample 2, PC-Pro(UK)
If I understand the question properly, you are looking for a different configuration file storage format that is akin to XML. One of the best strengths of XML though is the fact it gives you a structured data format. If you violate the DTD or "template" you have a poorly formed XML config file. In the past for some of my own development efforts, scripts, programs and apps, I had used INI formatted files. While INI's are easily parsed, and can support similar add, delete, updates, I favor XML b/c it is: