append XML Child - CSharp System.Xml

CSharp examples for System.Xml:XML Child

Description

append XML Child

Demo Code


using System.Xml.XPath;
using System.Xml;
using System.IO;/*from  w ww  . jav a 2 s.c om*/
using System.Collections;
using System;

public class Main{
        public static void appendChild(XmlNode root, XmlDocument doc2)
        {
            XmlNode nodeOrig = doc2.DocumentElement;
            XmlNode nodeDest = root.OwnerDocument.ImportNode(nodeOrig, true);

            root.AppendChild(nodeDest);
        }
        public static XmlDocument appendChild(XmlDocument doc1, XmlDocument doc2)
        {
            XmlNode rootDest = doc1.DocumentElement;
            XmlNode nodeOrig = doc2.DocumentElement;

            XmlNode nodeDest = doc1.ImportNode(nodeOrig, true);

            rootDest.AppendChild(nodeDest);
            return doc1;
        }
}

Related Tutorials