XML :: Delphi's TXmlDocument component can be used to either read (and process) an existing XML document or to construct a new, empty XML document.
Unfortunately, Delphi's implementation of the TXMLDocument component, which basically uses Microsoft XML parser by default, does not provide a way to add a node of the "ntDocType" (TNodeType type).
Read the full article for a Neat trick to add !DocType and ?XML to the TXmlDocument
Related: Exporting a TreeView to XML. Populating a TreeView from XML | Work with dynamically created TXMLDocument | Reading and Manipulating XML files (RSS feeds) with Delphi