0

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 fields.

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 fields 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.

Woody20
  • 791
  • 11
  • 30
  • Possible duplicate of [What XML parser should I use in C++?](http://stackoverflow.com/questions/9387610/what-xml-parser-should-i-use-in-c) – Fantastic Mr Fox Feb 17 '17 at 00:11
  • What value can the tag have? Also, is the name of the tag based on the value of ? – grimgrom Feb 17 '17 at 00:13
  • is one of "choices", "freeText" or "real". only appears when the type is "choices". That is why I said the number of choices varies by field (i e, it can be 0). – Woody20 Feb 17 '17 at 18:46

0 Answers0