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 42 43 44 45 46 47 48 49 50 51
|
Function RecupConfXml: Boolean;
var
confpath, fastpath: string;
finess, service, posteid, ns: string;
xmlconf, xmlfast, confbalise, fastbalise,nsmgr: variant;
begin
fastpath := 'c:\programdata\ici\la\fast.xml'; // emplacement du nouveau fichier de configuration
confpath := ExpandConstant('{pf32}')+ '\la\app\data\conf\conf.xml'; //emplacement de l'ancien fichier conf.xml
xmlconf := CreateOleObject('Msxml2.DOMDocument');
xmlfast := CreateOleObject('Msxml2.DOMDocument');
try
xmlconf.async := False;
xmlfast.async := False;
xmlconf.load(confpath);
xmlfast.load(fastpath);
if (xmlconf.parseError.errorCode <> 0) then
MsgBox('Le fichier conf.xml ne peut pas être analysé. ' +
xmlconf.parseError.reason, mbError, MB_OK)
else if (xmlfast.parseError.errorCode <> 0) then
MsgBox('Le fichier fast.xml ne peut pas être analysé. ' +
xmlfast.parseError.reason, mbError, MB_OK)
else
begin
xmlconf.setProperty('SelectionLanguage', 'XPath');
confbalise := xmlconf.selectSingleNode('//config/finess'); //recuperation de l'ancien code finess
finess := confbalise.text;
Log('le code finess récupéré est ' + finess);
confbalise := xmlconf.selectSingleNode('//config/service'); //recuperation de l'ancien code service
service := confbalise.text;
Log('le nom du service récupéré est ' + service);
confbalise := xmlconf.selectSingleNode('//config/posteId'); //recuperation de l'ancien code posteid
posteid := confbalise.text;
Log('le posteID récupéré est ' + posteid);
xmlfast.setProperty('SelectionLanguage', 'XPath');
ns := 'xmlns:model="model"'; //essai de declaration du namespace
xmlfast.setProperty('SelectionNamespaces', ns);
log('xmlfast.setProperty');
fastbalise := xmlfast.selectSingleNode('/ns:FastContext/ns:etabservice');
Log(fastbalise.text);
fastbalise.text := service;
xmlfast.save(fastpath);
end;
except
MsgBox('Une erreur est apparue!' + #13#10 + GetExceptionMessage, mbError, MB_OK);
end;
Result := False;
end; |
Partager