[jdom-interest] org.jdom.JDOMException

Dennis Sosnoski dms at sosnoski.com
Tue Apr 30 15:24:05 PDT 2002


Your best approach for processing this type of document depends on 
whether you actually need it all in memory at one time. If you do, you 
should be able to subclass the org.jdom.input.SAXBuilder to catch and 
ignore the exception. Since it occurs at the end of the document, the 
JDOM representation will have already been built and you can just return 
the document.

If you're really more interested in doing some processing of the data 
from the log (rather than wanting to work with it as a document) you may 
be better off using a parser directly. I just wrote a series of articles 
for JavaWorld discussing this, including both SAX2 and XMLPull parser 
approaches - XMLPull is probably easiest for the type of thing you're 
doing. The last article is at 
http://www.javaworld.com/javaworld/jw-04-2002/jw-0426-xmljava3.html?, it 
includes links to the earlier articles.

  - Dennis

Dennis M. Sosnoski
Sosnoski Software Solutions, Inc.
http://www.sosnoski.com

Elliotte Rusty Harold wrote:

> At 3:03 PM -0800 4/30/02, Gerardo Arroyo wrote:
>
>> Hi,
>>
>> I've a very simple question. I've a XML log file, this log contains 
>> all the
>> activity from a Java application server. There're some cases, by 
>> example:
>> when the server has a fatal error, or the PC is shutdown or anything 
>> else...
>> in such events the final end-tag is absent.
>>
>
> Then the file does not contain an XML document, and it cannot be 
> parsed by JDOM.  If you add the end-tag, then it will become a legal 
> XML document, and you can parse it.






More information about the jdom-interest mailing list