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)
-   -   Writing new nodes to XML File (https://www.kinook.com/Forum/showthread.php?t=2113)

jabaran 10-23-2006 08:22 AM

Writing new nodes to XML File
 
I'm probably missing something simple here but I would like to use update an xml file, not nessecarily existing nodes, but add new nodes to the structure. Is there a way of doing this? I see adding attributes isn't a problem but can't seem to figure out how to add children.

Thank you in advance.

jabaran 10-23-2006 08:29 AM

I think I found it with a bit more searching...
 
I think http://www.kinook.com/Forum/showthread.php?threadid=427 might provide enough of a sample. But if you have another way I'd be happy to read it!

jabaran 10-25-2006 01:28 PM

My solution
 
I ended up with a script that looked like list....

' script to update value attributes in a .NET config file
' requires MSXML v3.0+ to be installed --
' http://msdn.microsoft.com/library/de...xmlgeneral.asp

' load the settings xml document
Set msxml = CreateObject("MSXML2.DOMDocument")
msxml.async = False
msxml.load "%XML_FILE%"

Set root = msxml.documentElement
if root is nothing then
set root = msxml.createElement("Builds")
msxml.appendChild(root)
end if

'Get the node that contains the information about the last build
Set lastBuild = root.lastChild
if not (lastBuild is nothing) then
call lastbuild.setAttribute("NextBuildDate", "%Date%")
set buildNo = lastBuild.getAttributeNode("BuildNo")
if buildNo is nothing then
buildNo = -1
else
buildNo = buildNo.value + 1
end if
else
buildNo = 0
end if

'Create a new Release
Set thisRelease=msxml.createElement("Build")
call thisRelease.setAttribute("BuildNo", buildNo)
call thisRelease.setAttribute("BuildDate", "%dateTime%")
'Next build hasn't happened... set it off in the future... way off into the future...

call thisRelease.setAttribute("NextBuildDate", "12/31/9999")

'Append the new Release
root.appendChild(thisRelease)
' save the changes back out
msxml.save "%XML_FILE%"

The XML ends up looking like...




Maybe someone will find this useful...


All times are GMT -5. The time now is 05:54 AM.


Copyright © 1999-2023 Kinook Software, Inc.