Creating XML Document with C#

Here is the sample code to create XML document

private XmlDocument createDoc () {
        XmlDocument xmlDoc = new XmlDocument();
        XmlElement root = xmlDoc.CreateElement(“Root”);
            xmlDoc.AppendChild(root);
        XmlElement child = xmlDoc.CreateElement(“Child”);
        child.InnerText = “node Value”;
        root.AppendChild(child);
        return xmlDoc;
    }

Here is the sample code to create XML document private XmlDocument createDoc () {         XmlDocument xmlDoc = new XmlDocument();         XmlElement root = xmlDoc.CreateElement(“Root”);             xmlDoc.AppendChild(root);         XmlElement child = xmlDoc.CreateElement(“Child”);         child.InnerText = “node Value”;         root.AppendChild(child);         return xmlDoc;     }

Leave a Reply

Your email address will not be published. Required fields are marked *