public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteStartElement("Service"); writer.WriteStartElement("Element1"); writer.WriteString(Element1.ToString()); writer.WriteEndElement(); writer.WriteStartElement("Element2"); writer.WriteString(Element2.ToString()); writer.WriteEndElement(); foreach (string ele in Element3) { writer.WriteStartElement("Element3"); writer.WriteString(ele); writer.WriteEndElement(); } writer.WriteEndElement(); }