This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parse large xml files

 
Ramona Andreea
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I need some help. I want to parse a large xml which has this structure:
<start>
<node id="1" atr1="atr1" atr2="atr2"/>
<node id="2" atr1="atr1" atr2="atr2"/>
<node id="3" atr1="atr1" atr2="atr2"/>
<way id="10">
<nd ref="1"/>
<nd ref="2"/>
</way>
</start>

Foreach way tag I want to take the atr1 and atr2 values where the node id is equal with nd ref.

With SAX a can't take the childs and parents nodes. JDOM uses a lot of memory. Which library can I use to parse a very large xml with the structure above?

Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramona Andreea wrote:With SAX a can't take the childs and parents nodes.

Yes you can, but you must keep track of the structure yourself. You'll probably want some stack with the current elements. Upon a start tag you push the tag to the stack, upon an end tag you pop it.
 
Ramona Andreea
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I thought at this, but if are a lot of childs I'll use very large stacks and for a 1GB xml it will consume a lot of memory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic