I am trying to create an XML string but the expected output is different from this code
XmlDocument xml = new XmlDocument();
XmlElement root = xml.CreateElement("Employee");
xml.AppendChild(root);
for (int i = 1; i < datacount; i++)
{
XmlElement child = xml.CreateElement("EmployeeName");
child.SetAttribute("value", "Name1");
root.AppendChild(child);
}
string xmlString = xml.OuterXml;
Expected output:
<?xml version="1.0" encoding="utf-8" ?>
<Employee>
<EmployeeName>Name1</EmployeeName>
<EmployeeName>Name2</EmployeeName>
</Employee>
Current output:
<?xml version="1.0" encoding="utf-8" ?>
<Employee>
<EmployeeName Value = "Name1" />
<EmployeeName Value = "Name1" />
</Employee>
child.InnerText = "Name1";