brickerz
5th June 2013 16:10 UTC
NSISXML Usage
I'm trying to use nsisXML to replace data in a tomcat configuration file. I've just started with nsis and most of it makes sense, this last piece in modifying the xml files is escaping me. I would have liked to use a find/replace script, but I need to replace specific variables and not all of them.
This script keeps crashing at the colored line. Any assistance you could offer would be appreciated.
Function GetTomcatData
!insertmacro MUI_HEADER_TEXT $(PAGE_TITLE) $(PAGE_SUBTITLE)
Var /GLOBAL AppUrl
Var /GLOBAL AppUrlState
nsDialogs::Create 1018
${NSD_CreateLabel} 10% 15u 80% 12u "Enter Application FQDN (e.g. www.server.com)"
${NSD_CreateText} 10% 25u 80% 14u $AppUrlState
Pop $AppUrl
nsDialogs::Show
FunctionEnd
Function GetTomcatDataLeave
${NSD_GetText} $AppUrl $AppUrlState
nsisXML::create
nsisXML::load "C:\tomcat6\conf\server.xml"
nsisXML::select '/Server/Service/Engine/Host[@name="localhost"]'
nsisXML::getAttribute "name"
nsisXML::getText
nsisXML::setText $AppUrl
nsisXML::save "C:\tomcat6\conf\server.xml"
FunctionEnd
T.Slappy
7th June 2013 07:20 UTC
Have the XML files the same structure?
E.g. you are looking for the same XPath: '/configuration/connectionStrings/add' but you are not checking the returned values in $1 and $2.
If not found, reference will be 0 (zero) - are you getting non-zero values?
nwebeeNsis
30th September 2013 19:39 UTC
Hi,
i want to know how to insert elements in XML file using NSIS. Lets say I have one big XML file file1.xml with parent, child ..... structure. and I need to add\insert various elements in file1.xml.I have all data to insert in other file(xml or text file Ex:file2.xml).
Is it possible to insert elements to file1.xml from file2.xml? Aim is installer will keep adding element to file1.xml from file2.xml whenever executed.
Thanks a lot in advance.
T.Slappy
2nd October 2013 07:33 UTC
This is possible but if you are looking for some simple function like CopyElementWithHierarchy() there is no such thing.
You need to traverse the source tree (file), read desired elements and write them into appropriate place in destination file.