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
295 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

Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

628 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