[jdom-interest] JDom&DTD

NP nicola.padovano at gmail.com
Mon Oct 1 09:59:02 PDT 2007


i know that jdom doesn't validate the xml, but i can use the function 
build of the class SAXBuilder...i have solved the question, in this way:

code:
SAXBuilder builder = new SAXBuilder();
builder.setValidation(true);       // !!!!
builder.build(new File("myfile.xml"));

(note: in myfile.xml there is the line: <!DOCTYPE root_element SYSTEM 
"file.dtd">)

my mistake was don't write "builder.setValidation(true);"

So, if the xml doesn't respect the rules of dtd  file, Java throws a 
JDOMParseException with the explanation of the error.


More information about the jdom-interest mailing list