Jump to content

update an XML field


gcue
 Share

Recommended Posts

hello all.

i am trying to use _XMLUpdateField to update the value for field "userInactivityTimeOut".

here is the XML:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="lnet" type="lnet.LNetConfigHandler, lnet" />
    <sectionGroup name="sing">
      <section name="context" type="Sing.Context.Support.ContextHandler, Sing.Core"/>
      <section name="objects" type="Sing.Context.Support.DefaultSectionHandler, Sing.Core" />
    </sectionGroup>
  </configSections>
  <appSettings>
    <add key="production" value="true"/>
    <add key="environments" value="prod,dev" />
    <add key="environments.production" value="prod"/>
    <add key="ErrorMessageFile" value="cfgErrorMessageList.xml" />
    <add key="logging.file" value="log.config" />
    <add key="application.name" value="NETQ" />
    <add key="userInactivityTimeOut" value="1440000000" />
    <add key="userInactivityCheck" value="60000" />
    <add key="AddTimestampToAlerts" value="true" />
  </appSettings>
</configuration>

here is what i've tried so far (i can read the current value but stuck on trying to change it):

_XMLFileOpen($file)

    $aNodes = _XMLGetNodeCount("/configuration/appSettings/add")

    for $x = 1 to $aNodes
        $key = _XMLGetAttrib("/configuration/appSettings/add[" & $x & "]", "key")

        if $key = "userInactivityTimeOut" Then
            $timeout = _XMLGetAttrib("/configuration/appSettings/add[" & $x & "]", "value")
            ConsoleWrite($timeout & @CRLF)

;neither of the following work
            ;_XMLUpdateField("/configuration/appSettings/add[" & $x & "]", "22")
            ;_XMLUpdateField("/configuration/appSettings/add[" & $x & "]/value", "22")
            ;_XMLUpdateField("/configuration/appSettings/add[" & $x & "]/value/key", "22")
        EndIf
    Next

thanks in advance!

Edited by gcue
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...