473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

AppendChild of diff document

Trying to select a node 'E' from XML document 'ParentXML' and append the
same to another xml document 'ChildXML'
string MyXMLStr="<R><E A='1'/></R>";
XmlDocument ParentXML= new XmlDocument();
ParentXML.LoadXml(MyXMLStr);


XmlDocument ChildXML = new XmlDocument();
ChildXML.LoadXml("<R/>");

XmlElement tempE = (XmlElement) ParentXML.DocumentElement.SelectSingleNode
("E");

ChildXML.DocumentElement.AppendChild(tempE);
throws 'The node to be inserted is from a different document context.'
error.

Can I use Clone() or CloneNode() to achieve this.
A sample will be usefull.

hanks,
praveen

Feb 12 '07 #1
1 3112
Praveen wrote:
Trying to select a node 'E' from XML document 'ParentXML' and append the
same to another xml document 'ChildXML'
string MyXMLStr="<R><E A='1'/></R>";
XmlDocument ParentXML= new XmlDocument();
ParentXML.LoadXml(MyXMLStr);


XmlDocument ChildXML = new XmlDocument();
ChildXML.LoadXml("<R/>");

XmlElement tempE = (XmlElement) ParentXML.DocumentElement.SelectSingleNode
("E");

ChildXML.DocumentElement.AppendChild(tempE);
You need to use ImportNode
ChildXML.DocumentElement.AppendChild(ChildXML.Impo rtNode(tempE, true));

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Feb 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
3
by: jacster | last post by:
Hi, I'm using the following code in a Greasemonkey script. var start, newElement; start = document.body; newElement = document.createElement('b'); newText = document.createTextNode("The...
3
by: Robi | last post by:
I have the following code: ############## var nHead=(document.getElementsByTagName)?document.getElementsByTagName("head").item(0):document.head; var nStyle=document.createElement("style"); //...
2
by: samuel.adam | last post by:
Hi all, I am coding an AJAX DHTML whatever application and I was fed up with always typing a lot of appendChild() functions. I created a custom one called append_children() and wanted to share...
3
by: ezmiller | last post by:
So I have some code that gets the body element of another frame and then tries to dynamically write a table. The code fails when, after creating the table, I try to append it to the document. I...
4
by: Andreas Kasparek | last post by:
Hola! I'm preparing my master thesis about a XML Merge Tool implementation and was wondering if there is any open standard for XML diff regarding topics like: - is a diff result computed on...
2
by: Christina | last post by:
I have 2 list boxes - one to fill the second one based on the selection, or move all items. You can remove the selection (or all items) from the second one to place it back in the first one. I...
2
by: vsanjit | last post by:
Hi all, I've been trying to create a table dynamically upon the generation of en event using the appendChild method in Javascript. This seems to work fine in Firefox, but not in IE7. There's also...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.