Old 6th February 2009, 07:54   #1
Schwabbel82
Junior Member
 
Join Date: Feb 2009
Posts: 3
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.

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

code:

${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.

code:

${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.
Schwabbel82 is offline   Reply With Quote
Old 6th February 2009, 09:33   #2
Schwabbel82
Junior Member
 
Join Date: Feb 2009
Posts: 3
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:

PHP Code:
<settings>
  <
dbase>
    <
localDataDir ProgDir="true" AppDir="false" Directory="false"/>
    <
remoteDataDir NetBackup="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!
Schwabbel82 is offline   Reply With Quote
Old 6th February 2009, 16:59   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
That plug-in should work. Try using GoTo again after setting the attribute and before setting the node value.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th February 2009, 10:17   #4
Schwabbel82
Junior Member
 
Join Date: Feb 2009
Posts: 3
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.

code:
;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}

Schwabbel82 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump