Archive: 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
Var /GLOBAL AppUrl
Var /GLOBAL AppUrlState
nsDialogs::Create 1018
${NSD_CreateLabel} 10% 15u 80% 12u "Enter Application FQDN (e.g."
${NSD_CreateText} 10% 25u 80% 14u $AppUrlState
Pop $AppUrl

Function GetTomcatDataLeave
${NSD_GetText} $AppUrl $AppUrlState
nsisXML::load "C:\tomcat6\conf\server.xml"
nsisXML::select '/Server/Service/Engine/Host[@name="localhost"]'
nsisXML::getAttribute "name"
nsisXML::setText $AppUrl
nsisXML::save "C:\tomcat6\conf\server.xml"

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?


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.

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.