Hi all
I am new to xml,
I am using DOM parser for xml parsing, before i am going to parse my xml file I want to validating my xml file against the .dtd. could someone tell as how to do this. if possible please give me sample code.
I have written code for parsing xml as below
try{
//Create Document
Document
doc = null;
DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
DocumentBuilder db = dbf.newDocumentBuilder();
File file = new File(XMLFILE);
doc = db.parse(file);
NodeList nl = doc.getElementsByTagName("ITestFrame");
---statements
--statements
--
--
--
}catch(IOException e){
System.out.println("Caught Exception : "+e);
}
here before going for parsing i want check XMLFILE is according to dtd or not.
do we have any method for that.
Thanks
Vishnu