ElementHandler!
Register some handlers to your elements, and just deal with the subtrees as they flow in. You can detach as you go. So, you actually are processing the doc as it's read, pretty much, plus you're given the ability, if you app can process sequentially, of releasing the subtrees when you're done with them, freeing memory. -bob On Tue, 16 Jul 2002, Brain, Jim wrote: > I have a lot of this: > > Iterator i=el.elementIterator(); > while(i.hasNext()) { > item=(Element)i.next(); > name = item.getName(); > if (name.equals("General")) { > addGeneralInfo(item); > } else if (name.equals("Payment")) { > //addPaymentInfo(item); > } else if (name.equals("Financial")) { > //addFinancialInfo(item); > } else if (name.equals("Beneficiary")) { > //addBeneficiary(item); > } else if (name.equals("Coverage")) { > //addCoverage(item); > } else if (name.equals("SubAccount")) { > //addAccount(item); > } else if (name.equals("ServiceRequestData")) { > // dunno... > } else if (name.equals("ErrorMessage")) { > String error=item.getTextTrim(); > if(!error.equals("")) { > throw new ProcessException(100,error); > //throw new ProcessException(2102,"Policy not found. > Invalid Policy and/or Company Number"); > } > } > } > > Is there a better way to do this? I don't want to use Xpath all the time > (as it is expensive), but was wondering if others had come up with a better > way of doing this that does not involve the big if statement. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user