The C# code I&#039;m using is shown below. The output file looks almost exactly how a basic XML file should look, I believe. My only concern is that how come the code to create it looks rather inefficient? How come I need to do "folder = doc.CreateElement("folder")" for EVERY new node that I create?? Can&#039;t I just use the "folder" object as a template for a folder element? Shouldnt all I need to do is set the attribute value and the inner text, and then reuse "folder" element object to append the new node? This is what I am saying:<BR><BR>&#060;code&#062;<BR>XmlElement folder = doc.CreateElement("folder");<BR><BR>// Add first node<BR>folder.SetAttribute("name", "folder 1");<BR>folder.InnerText = "1st Node";<BR>root.AppendChild(folder);<BR> <BR>// Add second node<BR>folder.SetAttribute("name", "folder 2");<BR>folder.InnerText = "2nd Node";<BR>root.AppendChild(folder);<BR>&#060;/code&#062;<BR><BR>However, that did not work. Here&#039;s the (whole) code that does work for me:<BR><BR>&#060;code&#062;<BR>XmlDataDocument doc = new XmlDataDocument();<BR>XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", null, null);<BR>doc.InsertAfter(declaration, null);<BR><BR>XmlElement root = doc.CreateElement("file_system");<BR>doc.InsertAft er(root, declaration);<BR><BR>XmlElement folder;<BR><BR>// Add first node<BR>folder = doc.CreateElement("folder");<BR>folder.SetAttribut e("name", "folder 1");<BR>folder.InnerText = "1st Node";<BR>root.AppendChild(folder);<BR> <BR>// Add second node<BR>folder = doc.CreateElement("folder");<BR>folder.SetAttribut e("name", "folder 2");<BR>folder.InnerText = "2nd Node";<BR>root.AppendChild(folder);<BR><BR>// Output to file<BR>XmlTextWriter writer = new XmlTextWriter(@"d:XMLTest.xml", null);<BR>doc.WriteTo(writer);<BR>writer.Close();< BR>&#060;/code&#062;<BR><BR>Is this the correct and most efficient way to create an XML document dynamically? Please share with me better solutions. Thanks.