Inno setup: how to replace a string in an XML file?

The following (in quote) is the contents of the XML file, which is part of my package. I would like to replace the value c:\path\myapp.exeduring installation (with the real path when the user decided to install the application. Is this possible? How?

<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
   <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
      <listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
   </listAttribute>
   <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
   <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="c:\path\myapp.exe"/>
   <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="${resource_loc}"/>
</launchConfiguration>
+4
source share
1 answer

It is best to use the XML DOM to select and edit the required node as the proposed TLama .

Alternatively, you can install the template file with a known line in the place you want to replace. Then the file can be read as a string, modified and written back using something like:

[Code]
procedure WriteAppPath;
var
    FileData: String;
begin
    LoadStringFromFile(ExpandConstant('{app}\app.xml'), FileData);
    StringChange(FileData, 'XXXXXMARKERXXXXX', ExpandConstant('{app}'));
    SaveStringToFile(ExpandConstant('{app}\app.xml'), FileData, False);
end;

. , INI.

+6

Source: https://habr.com/ru/post/1527342/


All Articles