I was writing xml with c#, and I come up with a very long list of the same function- SetAttribute, wonder if anyone knows a smart way to write this code. I think about making an array but donot know how, anyone know how to write an array for this code?
XmlDocument doc = new XmlDocument();
XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "utf-16", null);
doc.AppendChild(decl);
XmlElement ChatMapper = doc.CreateElement("ChatMapperProject");
doc.AppendChild(ChatMapper);
XmlNode xmldocSelect = doc.SelectSingleNode("ChatMapperProject");
//Crteate Attribute
ChatMapper.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
ChatMapper.SetAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
ChatMapper.SetAttribute("Title", "");
ChatMapper.SetAttribute("Version", "1.5.1.0");
ChatMapper.SetAttribute("Author", "");
ChatMapper.SetAttribute("EmphasisColor1Label", "");
ChatMapper.SetAttribute("EmphasisColor1", "#000000");
ChatMapper.SetAttribute("EmphasisStyle1", "---");
ChatMapper.SetAttribute("EmphasisColor2Label", "");
ChatMapper.SetAttribute("EmphasisColor2", "#000000");
ChatMapper.SetAttribute("EmphasisStyle2", "---");
ChatMapper.SetAttribute("EmphasisColor3Label", "");
ChatMapper.SetAttribute("EmphasisColor3", "#000000");
ChatMapper.SetAttribute("EmphasisStyle3", "---");
ChatMapper.SetAttribute("EmphasisColor4Label", "");
ChatMapper.SetAttribute("EmphasisColor4", "#000000");
ChatMapper.SetAttribute("EmphasisStyle4", "---");