[jdom-interest] org.jdom.JDOMException

Laurent Bihanic laurent.bihanic at atosorigin.com
Thu May 2 00:46:47 PDT 2002


Gerardo Arroyo wrote:
> I want to be able to process the log file no matter of this missing end-tag.
> Is there any way to do that?? I'm using JDOM Beta 8.
> 
You could try with ElementScanner from the org.jdom.contrib.input.scanner 
package: It notifies listeners as soon as the elements they registered for 
have been parsed.
This will allow you app to process the log file log record by log record, 
until an error is encountered.

Your source will then look like:

public class MyClass implements ElementListener {
    ...

     FileInputStream file = new FileInputStream(IMXConfiguration.getLogFile());

     // Create scanner
     ElementScanner builder = new ElementScanner();

     // Register listener for all "logrecord" elements children of the "log" 
root element
     build.addElementListener(this, "/log/logrecord");

     // Parse file
     builder.parse(new InputSource(file));
   }

   public void elementMatched(String path, Element e) throws JDOMException {
     // Log record precessing code...
   }

Laurent




More information about the jdom-interest mailing list