Edit installed XML file according to user preferences in Inno Setup

Solution 1:

You probably just need to edit the file after the installation completes.

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
    SaveValueToXML(
      'C:\AutoScan.exe.config',
      '//configuration/system.serviceModel/client/endpoint/address',
      CustomEdit.Text);
  end;
end;

Also you should not load the value every time you get to the custom page, because you reset user preference, every time user returns back to the custom page.

You should load it only once in the InitializeWizard.

Either hard-code the default value.

Or if you really need to read it from the embedded file, you have to temporarily extract it.

procedure InitializeWizard;
var  
  CustomPage: TWizardPage;
begin
  CustomPage :=
    CreateCustomPage(
      wpWelcome, 'Custom Page',
      'Enter the new value that will be saved into the XML file');
  CustomEdit := TEdit.Create(WizardForm);
  CustomEdit.Parent := CustomPage.Surface;
  ExtractTemporaryFile('AutoScan.exe.config');
  CustomEdit.Text :=
    LoadValueFromXML(
      ExpandConstant('{tmp}\AutoScan.exe.config'),
      '//configuration/system.serviceModel/client/endpoint/address');
end;