i am trying to create XML using C# and i am aware of the traditional method of creating XML such as
XmlDocument doc = new XmlDocument();
XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.InsertBefore(xmlDeclaration, doc.DocumentElement);
XmlElement element1 = doc.CreateElement("", "body", "");
doc.AppendChild(element1);
XmlElement element2 = doc.CreateElement("", "type", "");
element1.AppendChild(element2);
XmlElement element3 = doc.CreateElement("", "Numbers", "");
element2.AppendChild(element3);
XmlElement element4 = doc.CreateElement("", "one", "");
XmlText text1 = doc.CreateTextNode("1");
element4.AppendChild(text1);
element3.AppendChild(element4);
now i want the element to be list of XMLelement and the text as a list of XMLtext. i am having a problem to append the childnodes of the element while using the list.
List<XmlElement> elements = new List<XmlElement>() {doc.CreateElement("", "type" ,""),doc.CreateElement("", "numbers" ,""),doc.CreateElement("", "one" ,""),doc.CreateElement("", "two" ,"") };
foreach (var elementss in elements)
{
elementss.AppendChild(elementss);
Console.WriteLine(elementss.ChildNodes);
}
please clarify whether i am right in implementing lists in this scenario..??? any help would be greatly appreciated.