Solved

how to replace or add xml nodes with ASP?

Posted on 2002-05-23
3
254 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now