Advertisement

01.14.2004 at 10:46AM PST, ID: 20850764
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

Create or replace a text node using VBScript

Asked by KathrynGZ in Extensible Markup Language (XML)

Tags: , ,

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</date_submitted>
      <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("Microsoft.XMLDOM")
oSAVEIdeasDOM.async = false
oSAVEIdeasDOM.load server.mappath("/finance/save/fpdb/SAVEIdeas.xml")
If oSAVEIdeasDOM.parseError.ErrorCode <>0 Then
oSAVEIdeasDOM.loadXML "<SAVEIdeas/>"
End If
set oRoot = oSAVEIdeasDOM.documentElement
QUERY = "/SAVEIdeas/SAVEIdea[SAVE_ID = '" & SAVE_ID & "']"
Set currNode = oRoot.selectSingleNode(QUERY)

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--

KathrynStart Free Trial
[+][-]01.14.2004 at 11:09AM PST, ID: 10113459

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.14.2004 at 11:40AM PST, ID: 10113748

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.14.2004 at 11:58AM PST, ID: 10113922

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.14.2004 at 12:04PM PST, ID: 10113985

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.14.2004 at 12:16PM PST, ID: 10114105

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.14.2004 at 12:36PM PST, ID: 10114316

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.14.2004 at 12:38PM PST, ID: 10114331

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Extensible Markup Language (XML)
Tags: vbscript, type, replacechild
Sign Up Now!
Solution Provided By: KathrynGZ
Participating Experts: 2
Solution Grade: A
 
 
[+][-]01.14.2004 at 12:43PM PST, ID: 10114391

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.14.2004 at 04:54PM PST, ID: 10116561

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32