Dear Coders,
I need a unit for Delphi 7 to create a XML file from the scratch and write values to it and read them at a later time.
When the empty XML file is created, we want to define all sections/subsections that are going to appear in the XML file and write values to them.
Suppose that we want to generate the following XML file:
**<DOCUMENT>
? <SectionA>
? ? ? ? ? ? <SectionA1>
? ? ? ? ? ? ? ? ? <keyA1>Hello<\keyA1>
? ? ? ? ? ? </SectionA1>
? ? </SectionA>? ? ? ? ? ?
? ? <SectionB>
? ?
? ? ? ? ? ? <SectionB1>
? ? ? ? ? ? ? ? ? <keyB1>Hello<\keyB1>
? ? ? ? ? ? </SectionB1>
? ? </SectionB>? ? ? ? ?
</DOCUMENT>**
We need a funtion to first define all the sections and subsections that our XML file will have. A possible solution would be the implementation of the following function:
CreateXMLSection(parentSectionName, SectionName);
For the above example it would be:
CreateXMLSection(nil, 'DOCUMENT');? ? // nil for the main section
CreateXMLSection('DOCUMENT', 'SectionA');
CreateXMLSection('DOCUMENT', 'SectionB');
CreateXMLSection('SectionA', 'SectionA1');
CreateXMLSection('SectionB', 'SectionB1');
Notice that we will NOT use same sub-sections names, so, the parent section can be found without ambiguity.
After we have defined the section names, we just insert data into it. Example (as shown above):
WriteString('SectionA1', 'keyA1', 'Hello World');
WriteString('SectionB1', 'keyB1', 'Hello World');
Functions that we need
------------------------------
CreateXML(pFileName)? // create an empty XML file
SaveXML();? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // save our XML to file
LoadXML(pFileName)? ? ? // load our previous saved XML file
CreateXMLSection(parentSectionName, SectionName);
WriteString(Section, Key, Value)
ReadString(Section, Key)
WriteBoolean(....)
ReadBoolean(....)
WriteInteger(....)
ReadInteger(....)
The solution must be written in Delphi 7.
Thanks,
A.
## Deliverables
Delphi 7, Windows