Norberto Lopes wrote:
> I'm having some difficulties deciding the best way to describe what I
> want, being the best given by efficiency when searching the tree and
> adding or removing elements.
>
> Which one do you think is best?
>
> 1st one:
> <example>
> <sum>2+1</sum>
> <sum>3*2</sum>
> <div>3/2</div>
> <div>1/2</div>
> <mult>3*5</mult>
> <mult>5*9</mult>
> </example>
>
> 2nd one:
> <example>
> <sums>
> <sum>2+1</sum>
> <sum>3*2</sum>
> </sums>
> <divs>
> <div>3/2</div>
> <div>1/2</div>
> </divs>
> <mults>
> <mult>3*5</mult>
> <mult>5*9</mult>
> </mults>
> </example>
>
> Or should I just use which I think is best? Are there some guidelines
> or concerns with this? I couldn't find any info on this, or if it is
> something I should worry when writing big xml files.
>
> Thanks in advance for any information.
>
Hi Norberto,
Unless your xml doc is really huge, my guess is that either way works
equally well as far as the parser is concerned. From a flexibility point
of view, I would avoid the second approach, because the enclosing
<sums></sums>, etc. elements really don't add anything, and they
preclude you from doing some things.
I would even suggest that in the first case, you would change the syntax
to something like:
<sum>
<item>2</item>
<item>1</item>
</sum>
or maybe:
<sum>
<item val=2 />
<item val=1 />
</sum>
because the operators are implied by the enclosing <sum> elements. (And
I suspect that you might run into parsing problems, depending on the
processor, with the division operator because it's a special character
in the context of an element.)
But even if you stick with what you have, a reason to use your first
approach is that it lets you write equations like:
5 * (20/(17+34))
in the form
<mult>5*
<div>20/
<sum>17+34</sum>
</div>
</mult>
which you might not want to do today, but which you can't do tomorrow if
you use your second form.
Best regards,
Rush
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml