How do I get the DOCTYPE tag into the XMLDocument after its parsed?
You need to do some preprocessing to the file( getDoctype ()), and then put it through the DOMParser again( setDoctype ()), which will produce a valid, well-formed XMLDocument with the DOCTYPE tag contained within. Here is an example: — new parser p := xmlparser.newParser; — parse dtd file xmlparser.parseDTD(p, dir || ‘/’ || dtdfile, root); dt := xmlparser.getDoctype(p); — parse input file xmlparser.setValidationMode(p, true); xmlparser.setDoctype(p, dt); xmlparser.parse(p, dir || ‘/’ || inpfile); — get document doc := xmlparser.getDocument(p); —————————————————— — Set DOCTYPE Tag —————————————————— xmldom.setDoctype(doc,’family’,’/tmp/family.dtd’,”); xmldom.writeToFile(doc, dir || ‘/’ || ‘familyout.txt’); Notes: dtdfile – varchar2 parameter for DTD File. dir – varchar2 parameter directory information inpfile – input xml file.