There are two types of updating of the xml file :
- Creation of a user profile
- Backup of annotations of a file of concordances
3.4.1. Creation of a user profile
The creation of a user profile is done in several stages:
- Instantiation of an object DomDocument
- Parsing the xml file with the function load of the object DomDocument
- Recovery of the document root
- Verify that the user name does not already exist with getElementById function
- Creation of a node « user » with the function createElement
- Changing parameters « id », « name », « pass » and « base » of the node « user » with setAttribute
- Adding the new node « user » to the root node with the function appendChild
- Backup the xml file with the save function
3.4.2. Backup of annotations of a file of concordances
The backup of an annotation is done in several stages:
- Instantiation of an object DomDocument
- Parsing the xml file with the function load of the object DomDocument
- Recovery of the node « user » corresponding to the user
- Recovery of the node « analyse » corresponding to the analysis file annotated by the user
If the node « analyse » don’t exist yet, it is created as follow:- Creation of the node « analyse » with createElement
- Changing parameter « id » of the node « analyse » with setAttribute
- Adding the new node « analyse » to the node « user » with the function appendChild
- Recovery of the node « project » corresponding to the line of analysis file annotated by the user
If the project exist:- Changing attributes « level » and « comments » of the node noeud « project »
Else:
- Creation of the node « project » with createElement
- Changing parameters « id », « level » and « comments » of the node « project » with setAttribute
- Adding the new node « project » to the node « analyse » with the function appendChild
- Backup the xml file with the save function