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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Data at the root level is invalid. Line 1, position 1 8 290
XML & .net 5 52
How to configure empty element in XML Document parser? 15 44
Selenium and Xpath 4 30
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
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…

749 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