0

Hello, I need to read an xml file and store the information from it, into a tree struct in java.

The xml format is the following:
<room>
<floor>
<shape>...</shape>
<dimensions>...</dimensions>
<orientation>...</orientation>
<style>...</style>
<other tags>...</other tags>
</floor>
<ceiling>
<shape>...</shape>
<dimensions>...</dimensions>
<orientation>...</orientation>
<style>...</style>
<other tags>...</other tags>
</ceiling>
<wall>
<shape>...</shape>
<dimensions>...</dimensions>
<orientation>...</orientation>
<style>...</style>
<other tags>...</other tags>
</wall>
<other tags1>...</other tags1>
</room>

The shape, dimensions, orientation, style and other tags have other elements inside.

Is there any way using SAX to parse the xml and create a Tree struct in java from this xml? Is it better implementation to use a vector for each level of the tree, or each node to be it shelf a vector?

I have tried to read the xml using the sax parser but I couldn't find a way to find out whether the element I read now is brother or child of another node.

Thanks in advance.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ezzaral
0

You would find those things much easier with a DOM parser, if that is an option. Otherwise, you have to keep track of the overall structure yourself.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.