1
votes

I want to create concrete data using Edit fields for input in Delphi 10.4 and XML Data Binding Wizard.

I have the XML schema and I used it to create the code below in Delphi.

Can you help me with the code below how to create concrete XML files?

This is what I got from the Data Binding Wizard:

function NewUnknown: IXMLGetBalance_Type;
begin
  Result := NewXMLDocument.GetDocBinding('Unknown', TXMLGetBalance_Type, TargetNamespace) as IXMLGetBalance_Type;
end;

{ TXMLGetBalance_Type }

procedure TXMLGetBalance_Type.AfterConstruction;
begin
  RegisterChildNode('consent', TXMLGetBalance_Type_consent);
  inherited;
end;

function TXMLGetBalance_Type.Get_Consent: IXMLGetBalance_Type_consent;
begin
  Result := ChildNodes['consent'] as IXMLGetBalance_Type_consent;
end;

{ TXMLGetBalance_Type_consent }

function TXMLGetBalance_Type_consent.Get_Type_: UnicodeString;
begin
  Result := ChildNodes['type'].Text;
end;

procedure TXMLGetBalance_Type_consent.Set_Type_(Value: UnicodeString);
begin
  ChildNodes['type'].NodeValue := Value;
end;

function TXMLGetBalance_Type_consent.Get_Target: UnicodeString;
begin
  Result := ChildNodes['target'].Text;
end;

procedure TXMLGetBalance_Type_consent.Set_Target(Value: UnicodeString);
begin
  ChildNodes['target'].NodeValue := Value;
end;

function TXMLGetBalance_Type_consent.Get_Id: UnicodeString;
begin
  Result := ChildNodes['id'].Text;
end;

procedure TXMLGetBalance_Type_consent.Set_Id(Value: UnicodeString);
begin
  ChildNodes['id'].NodeValue := Value;
end;

How can I use this code to create concrete XML files with data from Edit fields?

1
Thank you very much ! I understood now that. I have 1 more question, i am trying to connect to an API like this wich is not working : request :=(HTTPRio1 as AccountInfo_PT).getBalance(Unk); because the getBalance() function has parameter type getBalance wichs definition is in the WSDL file wich i imported so getBalance() function wants getBalance class type parameter wich is of class getBalance_type , how can i create this getBalance parameter from Unk wich is IXMLGetBalance_Type ?user14080807

1 Answers

1
votes

Simply call NewUnknown(), assign values to the properties of the returned IXMLGetBalance_Type as needed, and then save it to file. For example:

uses
  ..., UnitGeneratedByXMLWizard;

procedure TMyForm.DoSomething;
var
  Unk: IXMLGetBalance_Type;
begin
  Unk := NewUnknown;
  Unk.Consent.Type_ := ...;
  Unk.Consent.Target := ...;
  Unk.Consent.Id := ...;
  Unk.SaveToFile('path_to\myfile.xml');
end;

Have a look at Embarcadero's documentation for more details:

Using Code That the XML Data Binding Wizard Generates