# XML Input/Output

Saving and restoring your files is done by using XML supporting XPath. The complete persistence layer is described by ags_file.dtd installed on your system. There various classes involved by doing XML IO. It does it in stages as following for reading:

1. Parsing the XML tree and map nodes and objects.
2. Resolving XPath expressions retrieve objects by their nodes.
3. Do as needed callbacks of AgsFileLaunch to setup up the application.

Writing files does ommit the last step. The current AgsConfig is going to be embedded in your file. So you can have per project configuration. Certain objects implement AgsPlugin interface to do an abstraction of reading and writing xmlNode.

## Writing XML files

Writing files is pretty easy. You just have to instantiate AgsFile, set the application context, open it in read-write mode, call ags_file_write() and finally ags_file_close().

### Writing XML

## Reading XML files

Normally you instantiate a new application context to be used to load objects into. Create a file object by passing the application context and filename. Then open it and read the content. At the end you close the file descriptor. To use your application start the main loop.

### Reading XML