I have an application which will store a series of (float) values in an XML file. There could be upwards of 100,000 values so I am interested in keeping the size down, but I also want files to be readily accessible by third parties.
There seem to be various methods open to me as far as encoding the data within the XML:
1.
<data>
<value>12.34</value>
<value>56.78</value>
...
<value>90.12</value>
</data>
2.
<data>
<value v="12.34"/>
<value v="56.78"/>
...
<value v="90.12"/>
</data>
3.
<data>12.34
56.78
...
90.12
</data>
4.
<data>12.34, 56.78, ... 90.12</data>
and there are probably more variations as well.
I’m just curious to know the drawbacks (if any) to each of these approaches. Some may not be compliant for example.
I don’t think there’s a “better” way of doing it. Read my comment above for alternatives. But if you’re hooked on XML, then go with whatever works for you. I personally prefer something like this
Simply because it’s nice and easy to read, and keeps the tags smaller.
EDIT:
Remember, the fewer characters are in your XML, the smaller it will be. (again, why I suggest JSON), so if you can get it nice and tight, by all means do it.
EDIT:
Also, I know you didn’t ask, but I thought I’d show you what JSON would look like