NSIS имеет на выбор 4 плагина XML; NsisXML (от Wizou) , XML-плагин , NsisXML (от Joel) и NsXML
Использование NsisXML (Wizou):
Outfile "$%temp%\NSISTest.exe"
RequestExecutionLevel user
Installdir "$Temp"
Showinstdetails show
!include LogicLib.nsh
Page InstFiles
!define XMLFILE "$instdir\myxml.xml"
Section
StrCpy $9 "Did not exist"
nsisXML::create
nsisXML::load "${XMLFILE}"
${If} $0 = 0
;build a new basic XML file:
nsisXML::create
nsisXML::createProcessingInstruction "xml" 'version="1.0" encoding="UTF-8" standalone="yes"'
nsisXML::appendChild
nsisXML::release $2
${EndIf}
nsisXML::select '/choise'
${If} $2 = 0
StrCpy $1 $0
nsisXML::createElement "choise"
nsisXML::appendChild
${Else}
nsisXML::getText
StrCpy $9 $3
${EndIf}
DetailPrint "Old value: $9"
System::Call 'kernel32::GetTickCount()i.r5' ;Get some "random" value to save
nsisXML::setText "$5"
nsisXML::release $2
nsisXML::save "${XMLFILE}"
nsisXML::release $0
DetailPrint "Saved new value: $5"
SectionEnd
При первом запуске я получаю:
Old value: Did not exist
Saved new value: 709289703
Completed
и во второй раз я получил:
Old value: 709289703
Saved new value: 709308687
Completed