Solved

how to replace or add xml nodes with ASP?

Posted on 2002-05-23
3
259 Views
Last Modified: 2006-11-17
I can read XML nodes ok with ASP but how do you add or replace a node?
0
Comment
Question by:davesu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7030212
Here are some examples from MSXML parser documentation..

--------- Adding a node ------------
Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim newNode As IXMLDOMNode

xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
MsgBox root.xml
Set newNode = xmlDoc.createNode(NODE_ELEMENT, "VIDEOS", "")
root.appendChild newNode

---- Replacing a node--
Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim newElem As IXMLDOMElement
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
Set newElem = xmlDoc.createElement("PAGES")
root.childNodes.Item(1).replaceChild newElem, root.childNodes.Item(1).childNodes.Item(0)

-------- Removing ---
Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim currNode As IXMLDOMNode
Dim oldChild As IXMLDOMNode
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
Set currNode = root.childNodes.Item(1)
Set oldChild = currNode.removeChild(currNode.childNodes.Item(1))


0
 

Author Comment

by:davesu
ID: 7037011
this looks promising but it is VB - what's the ASP equivelant?
0
 
LVL 23

Accepted Solution

by:
naveenkohli earned 100 total points
ID: 7037064
davesu,
ASP is not a language. ITs a server side framework for parsing the scripts or code inclised between <% %> tags. Ultimately you will need a scripting language like VBScript or JavaScript to implement the XML functionlaity you are looking for. If you just put the <% %> aroudd this code, it becomes ASP page.

<%
Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim newNode As IXMLDOMNode

xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
MsgBox root.xml
Set newNode = xmlDoc.createNode(NODE_ELEMENT, "VIDEOS", "")
root.appendChild newNode
%>

Etc...

Naveen
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Obtain data from database .mdb 4 31
Asp in server side with Mssql Server 7 4 34
CREATE DATABASE 3 36
Converting Stored Procedure to SQL Statement 5 44
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question