VBSCRIPT - Is it possible to append to an already written to xml file from vbscript?

I've got a vbscript wrapper that excutes another vbs that in turn writes out an xml file. Once that is done I would like the wrapper to append to that file a certain value.

In this case is there anyway I can add a value under the colo=""  node in the below code from vbscript?

Thanks
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="serverhtml.xsl"?>
<computer>
 <generated script="sydi-server" version="2.1" scantime="2/11/2008 12:24:27 PM" />
 <system name="ALLHANDSARCH2" colo="" reboot="2/11/2008 3:17:25 AM" />
 <operatingsystem name="Microsoft Windows Server 2003 Enterprise Edition" servicepack="Service Pack 1" />
 <fqdn name="xyz.contoso.com" />
 <roles>
  <role name="File" />
  <role name="Media" />
 </roles>

Open in new window

WinPEAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
Hi, I'm not sure I follow, but you can add text to a file with VBS after it has been created, using
Const intForAppending  = 8
Set objOpenFile = objFSO.OpenTextFile("pathfilefile", intForAppending, False)
objOpenFile.Write vbCrLf & "New line"
objOpenFile.Close

that would, however, only append to the end of the file.  If you want to insert into the middle, you need to read the entire contents, searching for where you need to add text, then add the text, then write the contents back again.....

Regards,

Rob.
0
Shanmuga SundaramDirector of Software EngineeringCommented:
It is possible to read and write xml through vbscript.  To write in xml file using vb script you can do it as shown below. Also this link http://www.xmlfiles.com/dom/dom_access.asp will give you some ideas on how to do some other tasks related to xml file
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("note.xml")
 
for each node in xmlDoc.documentElement.childNodes
  document.write(node.nodename)
  document.write(": ")
  document.write(node.text)
next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shanmuga SundaramDirector of Software EngineeringCommented:
Also please check whether these links give you some ideas

http://www.devguru.com/technologies/xmldom/quickref/document_save.html
http://www.devguru.com/technologies/xmldom/quickref/document_save.html

Though this link doesnt give you a straight forward method to handle xml files, this might help you to handle it as text file

http://www.visualbasicscript.com/m_28119/tm.htm
0
WinPEAuthor Commented:
Thanks Guys!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.