title: Edit installed XML file according to user preferences in Inno Setup
body: <p>So I've been struggling with this problem for a few days now.
  Currently making an installer for our company software but the customer has to be able to fill in a URL that gets saved in the <code>app.exe.config</code>.</p>
  <p>I've been through a lot of googling and found this piece of code that I edited.</p>
  <pre class="lang-pascal prettyprint-override"><code>var
    CustomEdit: TEdit;
    CustomPageID: Integer;
  
  function LoadValueFromXML(const AFileName, APath: string): string;
  var
    XMLNode: Variant;
    XMLDocument: Variant;  
  begin
    Result := '';
    XMLDocument := CreateOleObject('Msxml2.DOMDocument');
    try
      XMLDocument.async := False;
      XMLDocument.load(AFileName);
      if (XMLDocument.parseError.errorCode &lt;&gt; 0) then
        MsgBox('The XML file could not be parsed. ' + 
          XMLDocument.parseError.reason, mbError, MB_OK)
      else
      begin
        XMLDocument.setProperty('SelectionLanguage', 'XPath');
        XMLNode := XMLDocument.selectSingleNode(APath);
        Result := XMLNode.text;
      end;
    except
      MsgBox('An error occured!' + #13#10 + GetExceptionMessage, mbError, MB_OK);
    end;
  end;
  
  procedure SaveValueToXML(const AFileName, APath, AValue: string);
  var
    XMLNode: Variant;
    XMLDocument: Variant;  
  begin
    XMLDocument := CreateOleObject('Msxml2.DOMDocument');
    try
      XMLDocument.async := False;
      XMLDocument.load(AFileName);
      if (XMLDocument.parseError.errorCode &lt;&gt; 0) then
        MsgBox('The XML file could not be parsed. ' + 
          XMLDocument.parseError.reason, mbError, MB_OK)
      else
      begin
        XMLDocument.setProperty('SelectionLanguage', 'XPath');
        XMLNode := XMLDocument.selectSingleNode(APath);
        XMLNode.text := AValue;
        XMLDocument.save(AFileName);
      end;
    except
      MsgBox('An error occured!' + #13#10 + GetExceptionMessage, mbError, MB_OK);
    end;
  end;
  
  procedure InitializeWizard;
  var  
    CustomPage: TWizardPage;
  begin
    CustomPage := CreateCustomPage(wpWelcome, 'Custom Page', 
      'Enter the new value that will be saved into the XML file');
    CustomPageID := CustomPage.ID;
    CustomEdit := TEdit.Create(WizardForm);
    CustomEdit.Parent := CustomPage.Surface;
  end;
  
  procedure CurPageChanged(CurPageID: Integer);
  begin
    if CurPageID = CustomPageID then
    begin
      CustomEdit.Text :=
        LoadValueFromXML('C:\AutoScan.exe.config',
          '//configuration/system.serviceModel/client/endpoint/address');
    end;
  end;
  
  function NextButtonClick(CurPageID: Integer): Boolean;
  begin
    Result := True;
    if CurPageID = CustomPageID then
    begin
      SaveValueToXML(
        'C:\AutoScan.exe.config',
        '//configuration/system.serviceModel/client/endpoint/address',
        CustomEdit.Text);
    end;
  end; 
  </code></pre>
  <p>and it does what is has to do if I specify an existing path like <code>C:\AutoScan.exe.config</code> but the setup starts complaining if the file doesn't exist.
  Of course the file only exists after it is installed. but in this case I want the file edited inside the installer I tried it with '{src}\AutoScan.exe.config' and '{app}\AutoScan.exe.config' but without result as the installer starts complaining it can't find the XML file</p>