Dear all, I want to convert an XML document containing a DOCTYPE declaration into one with a default namespace (i.e. the root element should become <ODM xmlns="http://www.cdisc.org/ns/odm/v1.2" ...>
So, what I do is: DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(true); Document doc = null; try { DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); doc = docBuilder.parse(xmlfile); // xmlfile is the input XML file } catch ... } doc.removeChild(doc.getDoctype()); // remove the DTD declaration doc.getDocumentElement().setAttribute("xmlns","http://www.cdisc.org/ns/odm/v1.2"); The last statement is known not to be correct. Maybe I could use: doc.createElementNS(...) to create a new root element and then add all the attributes and child nodes of the original document to the new element. But isn't there a better and faster way ? Many thanks in advance Jozef Aerts --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]