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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.