0
我在InstallShield项目中使用XML系统搜索和XML文件更改。在以前的安装中,用户为服务器选择了一个主机名和端口。当用户再次安装时,如果显示先前的设置,这将是理想的。这个想法是如果它使用XML系统搜索功能存在,则从XML文件读取值。如何在ISXmlLocator表的XPath表达式中使用名称空间?
我能够得到这个工作,因为XML不包含任何名称空间信息。下面是XML的没有命名空间的例子:
<?xml version="1.0" encoding="UTF-8"?>
<ApplicationSettings ProductVersion="2.4.0.0001" Version="1">
<Source Mechanism="Server">
<Server Host="127.0.0.1" Port="11111"></Server>
</Source>
</ApplicationSettings>
我使用去Server元素XPath查询:
/ApplicationSettings/Source/Server
如果我加入一些名称空间的信息,然后将XML系统搜索不起作用。
<?xml version="1.0" encoding="UTF-8"?>
<ApplicationSettings ProductVersion="2.4.0.0001" Version="1" xmlns="http://127.0.0.1/schema/ApplicationSetting.xsd">
<Source Mechanism="Server">
<Server Host="127.0.0.1" Port="11111"></Server>
</Source>
</ApplicationSettings>
我也试过以下的XPath表达式:
/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]
这并不工作,并在日志中似乎确实找到元素,而不是属性:
MSI (c) (84:C8) [10:47:17:836]: Invoking remote custom action. DLL: C:\Users\CZIETS~1\AppData\Local\Temp\MSIFF9E.tmp, Entrypoint: ISXmlAppSearch
InstallShield 10:47:17: Searching for an XML Attribute value using the Element '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]' and the Attribute 'Host'.
InstallShield 10:47:17: Attribute 'Host' not found using the following Element: '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]'. Check for the existence of the Attribute.
InstallShield 10:47:17: Searching for an XML Attribute value using the Element '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]' and the Attribute 'Port'.
InstallShield 10:47:17: Attribute 'Port' not found using the following Element: '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]'. Check for the existence of the Attribute.
Action ended 10:47:17: ISXmlAppSearch. Return value 1.
任何想法?
我发现了另一个问题的命名空间无关的搜索,它可能是错误的。那是我第一次尝试它。我会试试你的。 – Christo 2010-11-30 08:20:42