在XE2中,实现一个自定义函数,赋值给单元MSXMLDOMDocumentCreate
中的全局变量Xml.Win.msxmldom
:
uses
..., Xml.Win.msxmldom;
function MyCreateDOMDocument: IXMLDOMDocument;
begin
Result := CreateDOMDocument;
//...
end;
initialization
MSXMLDOMDocumentCreate := MyCreateDOMDocument;
在 XE3 中,从虚拟方法派生一个新类TMSXMLDOMDocumentFactory
并覆盖其虚拟CreateDOMDocument()
方法,然后将您的自定义类分配给单元中的全局TMSXMLDOMDocumentFactoryClass
变量Xml.Win.msxmldom
:
uses
..., Xml.Win.msxmldom;
type
MyFactory = class(TMSXMLDOMDocumentFactory)
public
class function CreateDOMDocument: IXMLDOMDocument; override;
end;
class function MyFactory.CreateDOMDocument: IXMLDOMDocument;
begin
Result := inherited CreateDOMDocument;
//...
end;
initialization
TMSXMLDOMDocumentFactoryClass := MyFactory;
无论哪种情况,一旦您有权访问IXMLDOMDocument
,您就可以根据需要自定义其属性和设置。