Search code examples
delphitxmldocument

Obtain IXMLDOMDocument2 from IXMLDocument


I am using Delphi 2010 with only the stock standard VCL libraries. The target system is win32.

If I have a reference to an IXMLDocument, how can I obtain an IXMLDOMDocument2 interface to the underlying object that IXMLDocument wraps?


Solution

  • function GetXMLDOMDocument2(const XMLDocument: IXMLDocument): IXMLDOMDocument2;
    begin
      Result := (XMLDocument.DOMDocument as IXMLDOMNodeRef).GetXMLDOMNode as IXMLDOMDocument2;
    end;