Hello, Berin!

BL> Also, while it is trivial to append strings, pulling the string back
BL> isn't so easy.

BL> For instance:

BL> <root>
BL>    <component>
BL>      <item>
BL>        <element/>
BL>      </item>
BL>      <item>
BL>        <element/>
BL>      <item>
BL>    </component>
BL> </root>

BL> We can trivially add to the path up until we reach the first close tag.
BL> At that time we have to rip off the current element's portion of the path.
BL> While the logistics can be solved with using a stack, I would like to
BL> avoid over-engineering this.

Just of academical interest: there may some easier ways then using
Stack, for instance a StringBuffer could be used.

Flavour 1:

when you need to rip off a path element and you know the length of the
name of the element that has just been closed, you just shorten the sb
by this length plus 1 (for the separator)

Flavour 2:

when you need to rip off a path element you just go searching the sb
from back to the begging untill you find the next separator (the '/'
char) and shorten the sb by that amount.

With a StringBuffer the amount of memory used will be way less then
for a Stack (in fact it will depend on the depth of the xml tree and
the lenghes of element names).

- Anton


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to