Srikanth
2nd June 2005 06:46 UTC
how do I write to a file
The requirement is to design a custom page, read few values from it, and then write them to a XML file. The XML file is like this –
<…>
<datasources>
<…>…<…>
<connection-url> “value to be read from custom page” </connection-url>
<username> “value to be read from custom page”</username>
<password> “value to be read from custom page”</password>
<…>…<…>
<datasources>
<…>
Can anyone please tell me how I can write to the XML file the values I read from the custom page( or how I can create a new XML file with those values)
Instructor
2nd June 2005 09:28 UTC
If you want create new XML file (Docs):
FileOpen $0 "C:\file.xml" w
FileWrite $0 '<username> "value to be read from custom page"</username>$\r$\n'
FileWrite $0 '<password> "value to be read from custom page"</password>$\r$\n'
FileClose $0
If you want modify existing XML you could try this:
Name "Output"
OutFile "Output.exe"
!include "TextFunc.nsh"
!insertmacro ConfigWrite
Section
StrCpy $0 'password'
StrCpy $1 ' "value to be read from custom page" '
${ConfigWrite} "C:\file.xml" "<$0>" "$1</$0>" $R0
IfErrors 0 +2
MessageBoX MB_OK "error" IDOK +2
MessageBoX MB_OK "$R0"
SectionEnd
Script use header
Note:
This script for complite line change,
<pane>
<guid>123</guid>
</pane>
NOT for
<pane>
<guid>123</guid></pane>