As far as we know MSXML DOM does not "directly" support creating DOCTYPE declaration statement. It has a node type enumeration (NODE_DOCUMENT_TYPE) - but creating a node of this type does not work.
We believe the options include using SAX to DOM and using LexicalHandler interface OR using the loadXML as outlined below:
Dim ObjXMLDoc As New MSXML2.DOMDocument40
Dim XMLStr As String
XMLStr = "<?xml version='1.0' encoding='UTF-8'?>" & _
"<!DOCTYPE Books SYSTEM 'Catalog.dtd'>" & _
"<RootElem />"
ObjXMLDoc.validateOnParse = False
ObjXMLDoc.resolveExternals = False
ObjXMLDoc.loadXML XMLStr
Debug.Print ObjXMLDoc.xml
We tried the above code and the SAX to DOM example using MSXML 4.0 SP1 and it worked fine.
Related KB Articles:
- FIX: DOCTYPE Subset Omitted in Cloned XML DOM (Q263586)
- PRB: loadXML Method Fails to Process DTD or Schema with Relative Path at the Server Side (Q254643)
- INFO: List of Issues Fixed in Microsoft XML 4.0 Service Pack 1 (Part 3 of 4)
|