I have two web forms which are filled in by the user. They contain different types of fields: text boxes, radio buttons, check boxes (single or in groups). All the information that user submits I store in XML field in a database.
My question is: what are the good practices for string that kind of informations in a XML file.
For now I do like this:
Text boxes, for example: txtName
I put into <Name>John</Name>
tags.
Radio boxes, for example: rdbSex
I put into <Sex>Male</Sex>
.
Check boxes groups I put into one XML tag and I specify true
or false
for each check box item, for example:
<favoriteMovies>
<StarWars>True</StarWars>
<KillBill>False</KillBill>
....
</favoriteMovies>
The movies are stored in the database in one table and each of those have an ID. Should I store it also in the XML file? Like this:
<favoriteMovies>
<StarWars id="4">True</StarWars>
<KillBill id="6">False</KillBill>
....
</favoriteMovies>
or maybe to store only selected choices (withoud KillBill in this case):
<favoriteMovies>
<StarWars id="4 />
....
</favoriteMovies>
The same problem is with dropdown controls. They are populated from one table in database and each item has an id. Should I store only the id of the user choise, or both: id and name of the choice. So it is better to store do like this:
<Address>
<City>2</City>
</Address>
or like this:
<Address>
<City id="2" />
</Address>
or like this
<Address>
<City>New York</City>
</Address>
The documents are submitted by the user, but they can be reopen and edited, and all the controls on the web site should be repopulated. So it seams I need ID of the city, to select appropriate value in DropDown control, but it makes the XML document less readable.
Are there any recommendations or some documents that specify the rules for storing web forms elements in XML documents?