Jump to content
RonaldK

Problem with XML DocBindung with 10.4.1

Recommended Posts

The following code doesn't work in Delphi 10.4.1 anymore:

uses
  Xml.XMLDoc, xml.XMLIntf;

type
  IXMLTest = interface(IXMLNode)
    ['{3BC4A779-907D-44D5-80A3-1C2D9F704D86}']
  end;
  TXMLTest = class(TXMLNode, IXMLTest)
  end;
  
procedure TForm2.Button1Click(Sender: TObject);
var
  LXmlDoc : TXmlDocument;
  LIXMLTest : IXMLTest;
begin
  LXmlDoc := TXmlDocument.Create (nil);
  LXmlDoc.Options := LXmlDoc.Options + [doNodeAutoIndent];

  LIXMLTest := LXmlDoc.GetDocBinding('TEST', TXMLTest, 'http://foo') as IXMLTest; // <-- Error in this line 'No active document'

end;

It run with no problem in previous  Delphi versions (up to 10.3) .

Does Delphi 10.4.1 losing an interface reference here? 
Any idea what's wrong. 

 

Edited by RonaldK

Share this post


Link to post
1 hour ago, Perpeto said:

If I remember it correctly, you have to set "LXmlDoc.Active := true".

Don't help.

 

A solution is changing declaration:

LXmlDoc : TXmlDocument;

to:

LXmlDoc : IXmlDocument;

Seems that code in 10.4.1 have different Interface RefCounter behaviour.

Edited by RonaldK

Share this post


Link to post

Strangeness today. When I copy/past the above code into the Delphi source editor

Last line has font display problems:

 

image.thumb.png.725da6164b27aa88c71ea4e45539d6fd.png

 

 

Edited by RonaldK

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×