[jdom-interest] JDOM on the fly
    Beleznay, Dave 
    Dave.Beleznay at webct.com
       
    Tue May 21 12:23:46 PDT 2002
    
    
  
Hi there,
I'm trying to do something that might already exist, but I'm not really sure so I'm asking here.  
I'd like to take an xml document such as:
<doc>
  <a/>
  <a/>
  <a/>
  <b/>
  <b/>
  <b/>
  <c/>
  <c/>
</doc>
and as the document is parsed with a sax parser,  make a jdom document (or element) for <a> and file it off to a handler,  make a jdom document for <b> and file it off to it's own handler, and similar for c (and d, e ....).  Basically,  I'd want something similar to,  
  Element ele = document.getRootElement();
  Iterator i = v.iterator();
  while (i.hasNext() )  {
    Element ele2 = ele.getChild( (String)i.next()  );
    if (ele.getName().equals("A")) {  
      //do something
    } else if (ele.getName().equals("B")) {
      //do something else
    }
  }
but without putting the whole document in memory at once.  
So my question,  does something like this already exist?  I'm looking at extending SAXHandler, or org.xml.sax.helpers.DefaultHandler directly,  (is that the right direction even?) but i'm not sure if there is a faster way.
Thanks,
Dave
-------
David Beleznay
Software Engineer
WebCT 
    
    
More information about the jdom-interest
mailing list