?
Solved

how to replace or add xml nodes with ASP?

Posted on 2002-05-23
3
Medium Priority
?
261 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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 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