> I am trying to validate an xml file with its DTD in Java using DOM
> preferably. Can anyone please help me ?
It is very simple !
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true); // <---- this is all it takes
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File(FNM));
Arne
Roedy Green - 30 Jul 2007 11:20 GMT
>DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>dbf.setValidating(true); // <---- this is all it takes
>DocumentBuilder db = dbf.newDocumentBuilder();
>Document doc = db.parse(new File(FNM));
I have worked that up into a complete program, posted at
http://mindprod.com/jgloss/xml.html#VALIDATION

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com