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 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.
Elements cannot overlap.
<name1> <XYZ> </XYZ> </name1> legal
<name1> <XYZ> </name1> </XYZ> not legal
Reading XML data is a little more work than writing it, but still not difficult. Since you wrote the file, you only need to be able to read what you wrote.
For this code segment, variable names with initial letter capitalized are assumed to have been declared global.
Table of Contents
XML for Data storage
by LaurenceBoyd Mar 20, 2014 6:21 am 497095900XML
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 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.
Elements cannot overlap.
<name1> <XYZ> </XYZ> </name1> legal
<name1> <XYZ> </name1> </XYZ> not legal
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 Data
Reading XML data is a little more work than writing it, but still not difficult. Since you wrote the file, you only need to be able to read what you wrote.For this code segment, variable names with initial letter capitalized are assumed to have been declared global.
19 Mar 2014 9:14