A C++ application contains an array field
, defined by
struct Field
{
char name[MAX_FLEN];
int pKind;
unsigned char type;
unsigned short nValues;
unsigned char valueIndex[MAX_FVAL];
char *pValue[MAX_FVAL];
};
unsigned int nFields;
Field field[MAX_DBF];
I need to store this information in an XML file. What would be an appropriate XML design for doing so? I will write the code for writing the file, given the array of field
s.
My first try was
<field>
<name>This is field 1</name>
<type>choices</type>
<kind>0</kind>
<choice>
<code>1</code>
<description>This is choice 1</description>
</choice>
<choice>
<code>2</code>
<description>This is choice 2</description>
</choice>
</field>
The number of fields varies, and the number of choices can be different for each field. The number of field
s and the number of choices are small (say, less than 100). The XML file should be readable by any common XML reader, so it should use only basic XML features. The character set is ASCII.
Edit: I am not asking for a package to read or write an XML file; this question asks for an XML design suitable for this kind of data.