Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Change XML element value (https://www.kinook.com/Forum/showthread.php?t=4963)

teognost 02-13-2012 12:01 PM

Change XML element value
 
If I need to change the value of 'interface' node from an xml doc like below -what is the VBScript syntax ?



12
1
1107
0
2012 M1
0
1



This one from your sample is working for an attribute:
Set elem = doc.selectSingleNode("appSettings/add[[@key='" & key & "']]")
elem.setattribute "value", value

but cannot manage to set interface node from 1107 to 1108 .

kinook 02-13-2012 12:39 PM

1 Attachment(s)
See attachment.

teognost 02-14-2012 07:02 AM

Thanks.
Unfortunately I cannot use the native VBP "Write XML" step ,therefore I use a VBScript step .

Finally I found the proper way :

Set msxml = CreateObject("MSXML2.DOMDocument.6.0")
msxml.async = False
msxml.load "%VERSION_FILE%"

Set bt = vbld_AllMacros()("BUILD_TYPE")
Set vi = vbld_AllMacros()("VERS_INTERFACE")
Set vix = vbld_AllMacros()("VERS_INTERFACE_XMLNODE")



' update some attributes
UpdateNode msxml, bt.Value ,vix.Value ,vi.Value

' save the changes back out
msxml.save "%VERSION_FILE%"

' function to update the value of a node
Function UpdateNode(doc, bldtype,node, value)

Set elem = doc.selectSingleNode("builds/"&bldtype&"/"&node)
elem.text =value
wscript.Echo "Node 'builds/"&bldtype&"/"&node&"' updated to:"&elem.text

End Function


All times are GMT -5. The time now is 05:15 PM.


Copyright © 1999-2023 Kinook Software, Inc.