![]() | Delphi Programming |
How to Create the !DocType and ?XML Elements using TXmlDocument Delphi componentDelphi's TXmlDocument component can be used to either read (and process) an existing XML document or to construct a new, empty XML document. To add nodes to a XML, you can use the "AddChild" method or the "CreateElement" methods - the result is the IXMLNode interface you then use to add leaf nodes, apply attributes, etc. One of the requirements for a valid XML is that it provides a "<!DOCTYPE ... >" (document type declaration) element and a "<?xml ... >" element, for example. 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). One of the solutions to this problem is to manually add required nodes by accessing the XML property of the TXmlDocument, as it is a TStrings object. Firstly, construct your XML document using AddChild methods.
Here's an example: varAnd here's the resulting XML: <?xml version="1.0"?>
Delphi tips navigator: |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


