Sign in to follow this  
Followers 0
gcue

update an XML field

2 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



this worked! (hadn't noticed this was available - was too fixated on _XMLUpdateField)

_XMLSetAttrib("/configuration/appSettings/add[" & $x & "]", "value", "144000000000")

Share this post


Link to post
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
Sign in to follow this  
Followers 0