[inno setup] modifier un XML avec une condition
bonjour,
C'est mon premier post sur ce site.
Je viens pour essayer de trouver une réponse a mon problème.
Disons plutôt que le problème, c'est moi, puisque je suis vraiment un noob dans le code. Disons que je fait du rapiéçage de code.
Je vous explique ce que je voudrais faire:
J'ai un XML déja écrit, je sais comment faire pour modifier un éléments dans mon XML avec ce genre de code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Const
XMLFileName = 'configuration.xml';
//============================================================
function NextButtonClick(CurPage: Integer): Boolean;
//============================================================
// selection themes
// selection icons
// selection sounds
// fulscreen
// ISTool Language
var
XMLDoc, xmlNode, NewNode: Variant;
Path: String;
ResultCode: Integer;
begin
if CurPage = wpFinished then begin
// Selection THEME XPERIENCE
if IsComponentSelected('theme')
and IsComponentSelected('theme\xperience') then begin
Path := ExpandConstant('{app}\data\');
{ Load the XML File }
XMLDoc := CreateOleObject('MSXML2.DOMDocument');
XMLDoc.async := False;
XMLDoc.resolveExternals := False;
XMLDoc.load(Path + XMLFileName);
if XMLDoc.parseError.errorCode <> 0 then
RaiseException('Error on line ' + IntToStr(XMLDoc.parseError.line) + ',position ' + IntToStr(XMLDoc.parseError.linepos) + ': ' + XMLDoc.parseError.reason);
//MsgBox('Loaded the XML file.', mbInformation, mb_Ok);
{ Modify the XML document }
xmlNode := XMLDoc.SelectSingleNode('//Entry[@Key="ScreensTheme"]/string');
xmlNode .lastChild.text := 'Xperience1080';
xmlNode := XMLDoc.SelectSingleNode('//Entry[@Key="ImagesTheme"]/string');
xmlNode .lastChild.text := 'Xperience1080';
xmlNode := XMLDoc.SelectSingleNode('//Entry[@Key="PropertyScreenFile"]/string');
xmlNode .lastChild.text := 'Home';
{ Save the XML document }
XMLDoc.Save(Path + XMLFileName);
Result:=True;
end;
end;
end; |
Maintenant je voudrais modifier un nœud en prenant en compte la valeur d'un autre nœud. J'utilise Xpath pour me faciliter la tache
Code:
1 2 3 4 5 6 7 8
| <AAA>
<BBB>
<CCC>only</CCC>
</BBB>
<DDD>
<EEE>modify</EEE>
</DDD>
</AAA> |
Je voudrais changer la valeur "modify" du noeud EEE seulement si le noeud CCC a la valeur "only" (exemple)
Voici un exemple partiel de mon XML:
Code:
1 2 3 4 5 6 7 8
| <description>
<Entry Key="plugin_id">
<guid>9cfe968d-0df2-4870-83c9-518e3c780a38</guid>
</Entry>
<Entry Key="enabled">
<boolean>false</boolean>
</Entry>
.... |
Je voudrais mettre TRUE sur <boolean>false</boolean> en tenant compte de l'ID qui est <guid>9cfe968d-0df2-4870-83c9-518e3c780a38</guid>
Je ne sais pas si je suis très explicite, sachant que je suis vraiment limité dans mes compétences.
Cependant, je vous remercie d'avance