读取Inno Setup中的XML属性值



使用如何在Inno Setup中读写XML文档节点值?我可以从XML文件中读取值。

我的文件不是XML类型,而是配置(myApp.exe.config)与XML配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="foo" type="bar">
<section name="foo2" type="bar2" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="foo3" type="bar3" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<entityFramework>
<defaultConnectionFactory type="foo, bar">
<parameters>
<parameter value="v12.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<clear />
<add name="AppEntities" connectionString="NEED THIS VALUE" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>  
</configuration>

在使用:

LoadValueFromXML(
ExpandConstant('{app}myApp.exe.config'),
'//configuration/connectionStrings/add');

LoadValueFromXML(
ExpandConstant('{app}myApp.exe.config'),
'//configuration/connectionStrings');

我仍然得到空字符串。我做错了什么?

参见通过XPath提取属性节点值

这里XPath是:

/configuration/connectionStrings/add/@connectionString

(还要注意单个前导/-因为<configuration>是根标记)

最新更新