public XmlDocument GenerateXmlDocument() { XmlDocument xmlDocument = GenerateXmlSkeleton(); int buildingObjectNumber = 0; iniFileAsString = readerService.GetIniFileAsString(); List <ProminObject> prominObjects = parserSerivce.SplitByUnits(iniFileAsString); foreach (var prominObject in prominObjects) { buildingObjectNumber++; XmlElement prominObjectXml = xmlDocument.CreateElement("ProminObject"); XmlElement sectorXml = xmlDocument.CreateElement("Sector"); XmlElement buildingNoXml = xmlDocument.CreateElement("BuildingNo"); XmlElement buildingObjectNumberXml = xmlDocument.CreateElement("BuildingObjectNo"); XmlElement gateNumberXml = xmlDocument.CreateElement("GateNo"); XmlElement bitXml = xmlDocument.CreateElement("Bit"); XmlElement codeXml = xmlDocument.CreateElement("Code"); XmlElement isInvertedXml = xmlDocument.CreateElement("IsInverted"); XmlElement ignoreNotification = xmlDocument.CreateElement("IgnoreNotification"); XmlElement typeXml = xmlDocument.CreateElement("Type"); sectorXml.InnerText = prominObject.sector.ToString(); buildingNoXml.InnerText = prominObject.buildingNo.ToString(); buildingObjectNumberXml.InnerText = prominObject.buildingObjectNo.ToString(); gateNumberXml.InnerText = prominObject.gateNo.ToString(); bitXml.InnerText = prominObject.bit.ToString(); codeXml.InnerText = prominObject.code.ToString(); isInvertedXml.InnerText = prominObject.isInverted.ToString(); typeXml.InnerText = prominObject.type; ArrayOfProminObject.AppendChild(prominObjectXml); prominObjectXml.AppendChild(sectorXml); prominObjectXml.AppendChild(buildingNoXml); prominObjectXml.AppendChild(buildingObjectNumberXml); prominObjectXml.AppendChild(gateNumberXml); prominObjectXml.AppendChild(bitXml); prominObjectXml.AppendChild(codeXml); prominObjectXml.AppendChild(isInvertedXml); prominObjectXml.AppendChild(ignoreNotification); prominObjectXml.AppendChild(typeXml); } xmlDocument.AppendChild(ArrayOfProminObject); xmlDocument.Save("ProminObject.xml"); return(xmlDocument); }