Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-23-2006, 08:22 AM
jabaran jabaran is online now
Registered User
 
Join Date: 10-23-2006
Posts: 3
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.
Reply With Quote
  #2  
Old 10-23-2006, 08:29 AM
jabaran jabaran is online now
Registered User
 
Join Date: 10-23-2006
Posts: 3
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!
Reply With Quote
  #3  
Old 10-25-2006, 01:28 PM
jabaran jabaran is online now
Registered User
 
Join Date: 10-23-2006
Posts: 3
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...
<Builds>
<Build BuildNo="1" BuildDate="10/25/2006 2:26:54 PM" NextBuildDate="12/31/9999">
</Builds>

Maybe someone will find this useful...
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off



All times are GMT -5. The time now is 08:40 AM.


Copyright © 1999-2023 Kinook Software, Inc.