I'm at that interesting point where a little knowledge is a dangerous thing :) Though not new to XML, I'm new to using VB Script to manipulate it. I'm starting out with a script I found on the web, and trying to add to it to get it to do what I want it to do.
First, here's a sample XML fragment:
<SAVEIdeas>
<SAVEIdea>
<SAVE_ID>1</SAVE_ID>
<date_submitted>1/13/04</d
ate_submit
ted>
<employee>Joe Anybody</employee>
<empnum>12345</empnum>
<location_/>
<department/>
<email1/>
<idea>blah blah</idea>
<implementation_steps/>
<present_cost/>
<new_cost/>
<net_savings/>
<cost_of_change/>
<cost_frequency/>
<who_makes_change/>
<target_change_date/>
<mgremail1/>
<submission_type/>
<status/>
<supervisor_comments/>
</SAVEIdea>
</SAVEIdeas>
<SAVEIdeas> is the root element.
Now, here's the VB Script I've got so far in a formhandler:
Set oSAVEIdeasDOM = Server.CreateObject("Micro
soft.XMLDO
M")
oSAVEIdeasDOM.async = false
oSAVEIdeasDOM.load server.mappath("/finance/s
ave/fpdb/S
AVEIdeas.x
ml")
If oSAVEIdeasDOM.parseError.E
rrorCode <>0 Then
oSAVEIdeasDOM.loadXML "<SAVEIdeas/>"
End If
set oRoot = oSAVEIdeasDOM.documentElem
ent
QUERY = "/SAVEIdeas/SAVEIdea[SAVE_
ID = '" & SAVE_ID & "']"
Set currNode = oRoot.selectSingleNode(QUE
RY)
So now currNode contains the child which I want to update: the contents of the <supervisor_comments> tag.
I have captured supervisor comments from a form on another page and assigned them to the variable supervisor_comments. (Yes, the name of the tag and the name of the variable are purposely the same.) For the sake of this example, let's assume the contents of supervisor_comments = "Great idea!"
Now, I need to replace <supervisor_comments/> in the XML file with
<supervisor_comments>Great
idea!</supervisor_comments
>
I've tried a ton of stuff with replaceChild that doesn't work. Can anyone tell me what *will* work?
Thanks in advance--
Kathryn
Start Free Trial