An simple XML configuration file scheme that mimics the behavior of the INIParser class. The main difference is, obviously, the storage format. This class uses XML instead of an INI file, thus removing the single-line data value limit, among other things.
Read the contents of an XML file into a class. There is an array data member for each tag, with the children as the array elements. Basically, it mirrors the section/key/value structure of an INI file.
Serializes the XML file into a string.
The configuration data as an XML string.
function writeFile( |
| ) |
Write the XML file back to the disk.
file | The filename to write to. Defaults to the filename property. |
True if the write succeeds, false otherwise.
function value( |
| ) |
Get a value from the XML file. The values are organized by section and key, just as in an INI file.
sec | The section of of the target key. |
var | The target key within that section. |
default | The optional default value if the target does not exist. |
A string containing the value of the given key, or the default value.
function valueIsSet( |
| ) |
Determine if a particular key has been set.
sec | The section of of the target key. |
var | The target key within that section. |
True if the given key has been set, false otherwise.
function setValue ( |
| ) |
Sets a value for a key.
sec | The section of of the target key. |
var | The target key within that section. |
val | The optional value. If omitted, the key is set to boolean true; |
The value to which the key was set.
function getSection( |
| ) |
Returns the given section as an array.
sec | The section of the file to get. |
An array of the section with variables as keys and values as elements.
Gets a list of the section names available in the file.
An array of strings, each of which is the name of a section.
function merge( |
| ) |
Merge another XML file into the current one. If a key from the other file is not set, it will be set with the value from the other file. Keys that are already set will not be modified.
file | The XMLINI object to merge with the current object. |