This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- XML Editing . . .
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 09, 2009
10:55 PM
XML Editing . . .
I'm using a Basic MSI Project.
I have a web.config whereing I need to put some paths, defined during run time by the user.
The problem is that the built in XML editor can't do the job, as each of the paths I need to change are between a pair ov value tags like this:
URL to be changed
If I load the xml file into the editor and tell it to change the value attribute, it basically changes it to:
URL to be changed
So it simply adds a value with the new URL inside the first tag . . .
I'm thinking I could read in the text from the xml file somehow, alter it and then write it back - basically doing some sort of text editing in an install script, but I'm not sure how, so if anyone can pinpoint me to a solution, feel fere to do so 🙂
I have a web.config whereing I need to put some paths, defined during run time by the user.
The problem is that the built in XML editor can't do the job, as each of the paths I need to change are between a pair ov value tags like this:
If I load the xml file into the editor and tell it to change the value attribute, it basically changes it to:
So it simply adds a value with the new URL inside the first tag . . .
I'm thinking I could read in the text from the xml file somehow, alter it and then write it back - basically doing some sort of text editing in an install script, but I'm not sure how, so if anyone can pinpoint me to a solution, feel fere to do so 🙂
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 19, 2009
06:11 AM
Easiest way i think of is creating a VBscript custom action and load & edit here the xml file. This is how we do it.
You have to change "value(s)" to your own names and values.
Example:
[SIZE="2"]Dim xmlDoc : Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(Session.Property("INSTALLDIR") & "Web.Config") Then
Dim objFile : Set objFile = objFSO.GetFile(Session.Property("INSTALLDIR") & "Web.Config")
Dim nFileAttributes : nFileAttributes = objFile.Attributes
If nFileAttributes And 1 Then
objFile.Attributes = objFile.Attributes - 1
End If
xmlDoc.async = False
xmlDoc.load(Session.Property("INSTALLDIR") & "Web.Config")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("Error " & myErr.reason)
Else
xmlDoc.selectSingleNode("//value/value[@key=""value""]").setAttribute "value", "value"
xmlDoc.Save(Session.Property("INSTALLDIR") & "Web.Config")
End If
objFile.Attributes = nFileAttributes
Set objFile = Nothing
End If
Set xmlDoc = Nothing
Set objFSO = Nothing[/SIZE]
You have to change "value(s)" to your own names and values.
Example:
[SIZE="2"]Dim xmlDoc : Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(Session.Property("INSTALLDIR") & "Web.Config") Then
Dim objFile : Set objFile = objFSO.GetFile(Session.Property("INSTALLDIR") & "Web.Config")
Dim nFileAttributes : nFileAttributes = objFile.Attributes
If nFileAttributes And 1 Then
objFile.Attributes = objFile.Attributes - 1
End If
xmlDoc.async = False
xmlDoc.load(Session.Property("INSTALLDIR") & "Web.Config")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("Error " & myErr.reason)
Else
xmlDoc.selectSingleNode("//value/value[@key=""value""]").setAttribute "value", "value"
xmlDoc.Save(Session.Property("INSTALLDIR") & "Web.Config")
End If
objFile.Attributes = nFileAttributes
Set objFile = Nothing
End If
Set xmlDoc = Nothing
Set objFSO = Nothing[/SIZE]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 19, 2009
11:35 AM
The InstallShield XML Changes view way of doing this, so long as it's writing a known value, is to use the Advanced tab of your element to "Set element content". Sorry I missed your question first time around.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 23, 2009
06:26 AM
Thanx mate, that worked - setting them under the advanced tab that is . . .
However, one of the settings has to be set to [TARGETDIR]Organization.config
This works, except that instead of the actual target dir it just sets it to C:\Organization.config so I figure the target dir, at the time when the XML thingie runs, contains a wrong argument . . .
Looks like I'll have to make an installscript that sets a different global (TARGETDIR2) or whatever, after the user has defined this dir . . .
Or ? ? ?
However, one of the settings has to be set to [TARGETDIR]Organization.config
This works, except that instead of the actual target dir it just sets it to C:\Organization.config so I figure the target dir, at the time when the XML thingie runs, contains a wrong argument . . .
Looks like I'll have to make an installscript that sets a different global (TARGETDIR2) or whatever, after the user has defined this dir . . .
Or ? ? ?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 23, 2009
11:23 AM
I think you might want [INSTALLDIR] instead of [TARGETDIR]. Have you tried that yet?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 24, 2009
02:53 AM
That did it - INSTALLDIR and not TARGETDIR . . .
Thanx mate 🙂
Thanx mate 🙂