Solved

Is it possible to using the appendchild method to load and external xml file to apend to the existing XML node

Posted on 2002-06-17
4
294 Views
Last Modified: 2010-08-05
Is it possible to using the appendchild method to load and external xml file to apend to the XML node
we specify in the program? Currently the normal way to do that is to create appropriate element, createTextNode
assign text to the element and finally using the node appendchild method to append the new record in.

 xmlDoc = new ActiveXObject('MSXML2.DOMDocument');
 xmlDoc.async = false;
 xmlDoc.load("tree/tree.xml");
 entity = xmlDoc.documentElement.selectSingleNode("//entity[@id='" + parentEntityID +"']");
 newEntity = xmlDoc.createElement("entity");
 attribute = xmlDoc.createAttribute("id");
 attribute.text = document.uniqueID;
 newEntity.attributes.setNamedItem(attribute);
 element = xmlDoc.createElement(entity.childNodes(0).baseName);
 element.text = '123';
 newEntity.appendChild(element);
 element = xmlDoc.createElement(entity.childNodes(1).baseName);
 element.text = 'images/paper.gif';
 newEntity.appendChild(element);
 element = xmlDoc.createElement(entity.childNodes(2).baseName);
 element.text = 'images/paper.gif';
 newEntity.appendChild(element);
 entity.selectSingleNode("contents").appendChild(newEntity);


is it another way where i can load the external XML file to append to the node in entity?
0
Comment
Question by:munchun
[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
4 Comments
 
LVL 14

Accepted Solution

by:
avner earned 100 total points
ID: 7085034
using MSXML you can use :

xmlDoc = new ActiveXObject('MSXML2.DOMDocument');
xmlDoc.loadXML("<ROOT><CHILD>text</CHILD></ROOT>");

Then you can append this object :
xmlDoc.documentElement , to some other element.


0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7092523
what avner has said is correct and straightforward. Is there anything else that you may need avner to clarify?
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

710 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