: I have some data that looks like this:
:
: 1 0.0000 0.0714 0.512 0.383
: 2 0.0000 0.1538 0.258 0.239
: 3 0.2500 0.0800 0.256 0.109
: 4 0.0000 0.1154 0.213 0.132
: ... ... ... ... ...
: 365 0.5000 0.0370 0.034 0.012
:
: that I want to put in xml format.
:
: The 'brute force' method would be:
: <day>
: <number> 1 </number>
: <percent1> 0.0714 </percent1>
: <percent2> 0.512 </percent2>
: <percent3> 0.383 </percent3>
: <percent4> 0.0 </percent4>
: </day>
: and so on for 365 days.
:
: Another method would be to have one string per line
: <dayString>4 0.0000 0.1154 0.213 0.132 </dayString>
: and then in the code parse the line into numbers.
:
: Each of these 2 methods has advantages/disadvantages.
: Are there any other better ways?
Your latter suggestion would make for a smaller file, but rather negates the purpose of using XML in the first place. If all the pertinent values are going to be a single string in your XML that needs to be parsed later, what's the point of using XML instead of the plain file?
I would do one of the following:
<data>
<day>
<percentage>0.0000</percentage>
<percentage>0.0714</percentage>
<percentage>0.512</percentage>
<percentage>0.383</percentage>
</day>
...
</data>
Or perhaps:
<data>
<day pct1="0.0000" pct2="0.0714" pct3="0.512" pct4="0.383" />
...
</data>
As long as the days will always be in numerical order, I don't think you need to include the number in the data.
infidel
$ select * from users where clue > 0
no rows returned