XML is a flexible, convenient, way of storing data, once you understand how.
Programs typically evolve thru several versions. This often results in different data items being stored. This has meant careful tracking of data version vs program versions, as programs could not correctly read data from the wrong data version.
XML is a flexible as names are stored with the data. Names which are understood can be read, while others are ignored. The downside is that missing variables may require defaults.
XML is a very convenient to use. The rules are quite simple.
XML consists of elements:
<name> text </name>
Every opening <name> is paired with a closing </name).
Names can be almost anything but are case sensitive.
Elements can be wholly contained within other elements: <Name1> <xyz> </xyz> </Name1>
Elements cannot overlap:<Name1> <xyz> </Name1> </xyz>
Reading XML data is a little more work than writting it, but still not dificult. Since you wrote the file, you only need to be able to read what you wrote.
For this example code segment, variable names with initial letters are assumed to have been declared global.
XML for Data storage
XML
XML is a flexible, convenient, way of storing data, once you understand how.Programs typically evolve thru several versions. This often results in different data items being stored. This has meant careful tracking of data version vs program versions, as programs could not correctly read data from the wrong data version.
XML is a flexible as names are stored with the data. Names which are understood can be read, while others are ignored. The downside is that missing variables may require defaults.
XML is a very convenient to use. The rules are quite simple.
XML consists of elements:
<name> text </name>
Every opening <name> is paired with a closing </name).
Names can be almost anything but are case sensitive.
Elements can be wholly contained within other elements: <Name1> <xyz> </xyz> </Name1>
Elements cannot overlap:<Name1> <xyz> </Name1> </xyz>
for more details visit: http://www.w3schools.com/xml/xml_syntax.asp
Saving Data
The following example shows only the code to open and write a file.
Example data file:
Reading XML
Reading XML data is a little more work than writting it, but still not dificult. Since you wrote the file, you only need to be able to read what you wrote.For this example code segment, variable names with initial letters are assumed to have been declared global.