S
steve_marjoribanks
If I have an XML document with some elements like this:
<line>
<point>0 2</point>
<point>1 4</point>
<point>3 5</point>
etc.
</line>
ie. a collection of points which I want to extract the coordinates of
from the XML file and draw them using Java.
I was thinking I can obviously use the startElement method and use a
test to see if it's a <point> element and then use the characters
method to extract the coordinates as strings and cast them to intergers
and store in an array or similar. This might sound like a silly
question but will the parser always traverse through the XML document
in order parsing as it goes? ie, if using the method just described,
will the coordinates of the points be stored in the correct order in
the array?
Also, if my XML document was like:
<line>
<point>5 1</point>
<point>4 8</point>
etc
</line>
<line>
<point>3 4</point>
<point>4 1</point>
etc
</line>
etc
how would I go about making sure that the point coordinates for each
line remain separate from each other and do not get mixed up?
I'm starting to think that DOM might have been a better idea than SAX!!
:-(
Steve
<line>
<point>0 2</point>
<point>1 4</point>
<point>3 5</point>
etc.
</line>
ie. a collection of points which I want to extract the coordinates of
from the XML file and draw them using Java.
I was thinking I can obviously use the startElement method and use a
test to see if it's a <point> element and then use the characters
method to extract the coordinates as strings and cast them to intergers
and store in an array or similar. This might sound like a silly
question but will the parser always traverse through the XML document
in order parsing as it goes? ie, if using the method just described,
will the coordinates of the points be stored in the correct order in
the array?
Also, if my XML document was like:
<line>
<point>5 1</point>
<point>4 8</point>
etc
</line>
<line>
<point>3 4</point>
<point>4 1</point>
etc
</line>
etc
how would I go about making sure that the point coordinates for each
line remain separate from each other and do not get mixed up?
I'm starting to think that DOM might have been a better idea than SAX!!
:-(
Steve