XML File
Is it possible with NSIS to write to a .xml file?
26 posts
There's no plugin written for creating XML files, but you can create one with the NSIS FileOpen, FileWrite, and FileCloseYou can't create plugins with NSIS itself. But you can create a function or macro for the job.
ClearErrorsAnd I cannot open the installer.
FileOpen: $INSTDIR\sam2.core.xml as w -> $7
IfErrors ?done:
FileWrite expects 2 parameters, got 3.
Usage: FileWrite $(user_var: handle input) text
Error in script "C:\WINDOWS\Desktop\installer\script.nsi" on line 184 -- aborting creation process
ClearErrors
FileOpen $7 $INSTDIR\sam2.core.xml w
IfErrors done
FileWrite $7 '<CONFIG application="SAM" version="2.8.3"><Database><Host>$host</Host><Port>$port</Port><Database>$base</Database><Username>$username</Username><Password>$pass</Password></Database>'
FileClose $7
done:
Originally posted by deguixNo deguix, I'm saying he can create an XML file with FileOpen, FileWrite, and FileClose 😁
You can't create plugins with NSIS itself. But you can create a function or macro for the job.
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
End tag 'Station' does not match the start tag 'CONFIG'. Error processing resource 'file:///C:/Program Files/WiFOX/SAM2/SAM2.core.xml'. Line 1, Position 232
<CONFIG application="SAM" version="2.8.3"><Database><Host>localhost</Host><Port>3306</Port><Database>SAMDB</Database><Username>rootname</Username><Password>strege</Password></Database>l><ICQ></ICQ><AIM></AIM><TouchAR>-1</TouchAR></Station><Member><MemberID>0</MemberID><Username></Username><Password></Password></Member><Plugins><Readers><e0VDQzIyMEVELTA5ODktNDgwNC1CN0M5LTI1N0NGRTJCMDYxMX0><MustReadInfo>0</MustReadInfo><Name>Standard file reader</Name><Description>Reads files files from standard sources (Harddisk or Network).
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^
No deguix, I'm saying he can create an XML file with FileOpen, FileWrite, and FileCloseI need a wake up call, two posts and I was still not seeing what was really going on! 😁 I did even put a wrong command syntax there which the correct is:
I'm certainly smart 😉.FileOpen $0 "filename.ext" a
It's slow but not that slow so don't worry. A lot of NSIS functions are slow compared to how fast they'd be when written in ie C++.That's true. 👍
Exch $0 ;file
Exch
Exch $1 ;line number
Exch 2
Exch $2 ;string to write
Exch 2 What do I do here? Should I define these variables earlier in my script? Do I replace the $0 or $1 or $2 with their values?Push "blablabla" ;text to insert
Push "13" ;line number
Push "$INSTDIR\file.txt" ;file name
Call WriteToFileLine