[jdom-interest] Test For Well Formed XML

L Rutker lrutker at hotmail.com
Tue Oct 23 08:49:54 PDT 2001


What is the proper way to test that the XML file you plan to use to create a 
Document for well formedness? I obviously can try to build a Jdom Document 
using the SaxBuilder classes and catch the exception.
Is this the right way to do it?
String filePath="c:\\not_well_formed.xml";
try {
        SAXBuilder builder =  new SAXBuilder(false);
        Document doc = builder.build(filePath);
} catch (JDOMException e) {
        if (e.getCause() != null) {
                e.getCause().printStackTrace();
         } else {
                e.printStackTrace();
         }
} catch (Exception e) {
            e.printStackTrace();
}

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




More information about the jdom-interest mailing list