J'utilise la recherche de système XML et les modifications de fichiers XML dans un projet InstallShield. Lors d'une installation précédente, un utilisateur a sélectionné un nom d'hôte et un port pour un serveur. Lorsque l'utilisateur installe à nouveau, il serait idéal si les paramètres précédents sont affichés. L'idée est de lire les valeurs du fichier XML si elles existent en utilisant la fonction de recherche de système XML.Comment utiliser un espace de noms dans l'expression XPath dans la table ISXmlLocator?
Je suis en mesure d'obtenir ce travail étant donné que le XML ne contient aucune information d'espace de noms. Voici un exemple de XML sans un espace de noms:
<?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>
La requête XPath J'utilise pour se rendre à l'élément serveur est:
/ApplicationSettings/Source/Server
Si j'ajoute des informations d'espace de noms, puis le système XML La recherche ne fonctionne pas.
<?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>
J'ai aussi essayé l'expression XPath suivante:
/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]
Cela ne fonctionne pas et dans le journal, il semble qu'il ne trouve l'élément, mais pas l'attribut:
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.
Des idées?
J'ai trouvé la recherche d'espace de nom agnostique sur une autre question et peut-être tort. C'était la première fois que je l'essayais. Je vais essayer avec le tien. – Christo