Archive: XML Plugin Edit Attribute and Value of a Node


XML Plugin Edit Attribute and Value of a Node
Hello everybody, i use NSIS 2.43 with XML Plugin v2.0
and I have big trouble to edit a xml file.

The file looks like the following example.

<settings>

<
dbase>
<
localDataDirProgDir="false"AppDir="true"Directory="false"/>
<
remoteDataDirNetBackup="true">C:Temp</remoteDataDir>
</
dbase>
</
settings>
Now i want to edit the first node "localDataDir" with
the following code and that works.


${xml::LoadFile} "$INSTDIR\settings.xml" $0
${xml::GotoPath} "/settings/dbase/localDataDir" $0
${xml::FirstChild} "" $0 $0
${xml::SetAttribute} "ProgDir" $bProgDir $0
${xml::SetAttribute} "AppDir" $bAppDir $0
${xml::SetAttribute} "Directory" $bDirectory $0


But to edit the second node I have the problem that I can't
edit the attribute and the value at the same time, if I edit
only the attribute it works and if I edit only the value
it works too but not both.


${xml::GotoPath} "/settings/dbase/remoteDataDir" $0
${xml::FirstChild} "" $0 $0
${xml::SetAttribute} "NetBackup" $bNetBackup $0
${xml::SetNodeValue} $Dir
${xml::SaveFile} "$DYNFILES\${FILE_DYN_SETTINGS}" $0

${xml::Unload}


I don't know where the problem is.

At the moment nothing works, so my new question how can i edit a xml file in my installer?

The layout of the xml file:

<settings>

<
dbase>
<
localDataDirProgDir="true"AppDir="false"Directory="false"/>
<
remoteDataDirNetBackup="true">C:Temp</remoteDataDir>
</
dbase>
</
settings>
I want to change the three attributes at "localDataDir",
the attribute at "remoteDataDir" and the node value of
"remoteDataDir".

Tell me how I can do it!

That plug-in should work. Try using GoTo again after setting the attribute and before setting the node value.


Now everything works. The problem was that i didn't need use "FirstChild" before use "SetAttribute" but to change the nodevalue I must use the "FirstChild" command.

;load XML file
${xml::LoadFile} "$DYNFILES\${FILE_DYN_SETTINGS}" $0

;localDataDir
${xml::GotoPath} "/settings/dbase/localDataDir" $0
${xml::SetAttribute} "ProgDir" $bProgDir $0
${xml::SetAttribute} "AppDir" $bAppDir $0
${xml::SetAttribute} "Directory" $bDirectory $0

;remoteDataDir
${xml::GotoPath} "/settings/dbase/remoteDataDir" $0
${xml::SetAttribute} "NetBackup" $bNetBackup $0
${xml::FirstChild} "" $0 $1
${xml::SetNodeValue} $Dir

;save XML file
${xml::SaveFile} "$DYNFILES\${FILE_DYN_SETTINGS}" $0
${xml::Unload}