Hi I'm Writing application , the application require a knowledge and skills in C# dotNet framework , I'll write my experience about C# XML .
XmlDocument xmlDoc = new XmlDocument(); // create xml document Object XmlElement xmlRoot = xmlDoc.CreateElement("RootTag"); // create root tag
XmlElement Attributes = xmlDoc.CreateElement("Attributes"); // I create another tag called it Attributes of course you can change it.
XmlElement element; // create reference for XML element
element = xmlDoc.CreateElement("child");
element.InnerText = "Hello World from Child";
Attributes.AppendChild(element); // append XML Element to parent node
XmlElement parameters = xmlDoc.CreateElement("parameters");
for (int i = 0; i < 10; i++){
XmlElement node = xmlDoc.CreateElement("parameter");
node.SetAttribute("id", "value"); // adding attribute
node.SetAttribute("Name ","string");// adding attribute
parameters.AppendChild(node);// adding node to parent Tag}
xmlRoot.AppendChild(Attributes);// adding Attributes to RootTag
xmlDoc.AppendChild(xmlRoot); // adding RootTag to XmlDoc
xmlDoc.Save("fileName.xml"); // saving the XML fileI hope this tutorial help you , thank you for Reading :)
Ahmed Ghazey
Comments
Post a Comment