Print Page | Close Window

Inserting element in XML

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5566
Printed Date: 30 March 2026 at 9:29pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Inserting element in XML
Posted By: tisaspdeveloper
Subject: Inserting element in XML
Date Posted: 06 September 2003 at 5:47am

Hi,

my xml file is

<?xml version="1.0"?>
<BOOK ID="BOOK">
  <METADATA>
   <BOOKTITLE>Glencoe Mathematics Applications and Concepts Part 1</BOOKTITLE>
  </METADATA>
  <BOOKSUBTITLE>Student Edition</BOOKSUBTITLE>
  <ISBN>0078600596</ISBN>
  <PUBLISHER/>
  <SUBJECT/>
  <AUTHOR/>
  <GRADE/>
</BOOK>

and I want to insert a new element into this using the following code

<%
set xmlDoc = server.CreateObject("Msxml2.DOMDocument")
xmlDoc.Load(Server.Mappath("insertChild.xml"))
set root = xmlDoc.documentElement
set newElem = xmlDoc.createElement("ANUNAY")
set newNode = xmlDoc.createNode("element","ASHISH","")
Response.write newElem.nodeName + " " + newNode.nodeName + "<br>"
Set refElem = root.childNodes.item(6)
root.insertBefore newElem, refElem
Response.write refElem.nodeName
%>

but I am not able to though no error is thrown. Please suggest me the remedy.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net