How to dynamically create, use and release TXMLDocument (no access violation error)
If you need to use dynamically create TXMLDocument components, once you try to release the object, you may get a violation error (Access Violations).
If TXMLDocument is used as a component, its survival period is controlled by its owner (you place the form of the form), if it creates but no owner, then its lifetime will be controlled by the IXMLDocument interface. Create a TXMLDocument You should always assign results to an IXmldocument interface.
As an interface, it will be released automatically. If it is a local variable, it will be released when the method returns. You can release it in a clear text:
Xmldoc: = nil;
~~~~~~~~~~~~~~~~~~~~~~~~~ xmldoc: = txmldocument.create (nil); try xmldoc.active: = true; // Use XMLDoc XMLDOC .Act: = false; finallyxmldoc: = nil; end; ~~~~~~~~~~~~~~~~~~~~~~~~~