You are laboring under a misconception. SAXparsers call handler routines with events that your code must interpret. Furthermore, an Element can't exist by itself, it must always have a parent Document. You could create an empty Document and build Elements from the events produced by your SAX parser. Have you done experiments that indicate a performance problem with having a DOM created from your XML? Bill
Hi Bill, Thank you for your response. Actually I did some small experiments with my code. 1) The document is not too big right now but it's supposed to grow fast. Parsing and getting root element (let's say - clients) takes 1 second. 2) What really surprised me was the fact that getting particular client element (by an attribute) from the document took the same 1 second. That's why I thought maybe there is some way around to avoid loading the whole document in a memory and get just the element I need.
Author and all-around good cowpoke
Joined: Mar 22, 2000
You are on the right track if you ONLY need the contents of one relatively small element out of a big XML document. However, you won't get an Element - instead you will have to provide a "handler" to look at the SAX events. That handler will have to recognize the start of the element you want and provide for saving the data as it is parsed on the fly, presumably putting it in some sort of holder data structure or class. Bill
Joined: Feb 06, 2002
I feel like I'm reinventing the wheel. It seems to be so obvious that parse method should be able to return some element... My plan is: 1. To implement DefaultHandler and write element content into an input stream. 2. Parse new input stream. Unfortunately it doesn't mean that parse() method won't create whole original document structure in a memory. This is what I would like to avoid. Any thoughts?