/// <summary> /// 保存XML配置 /// </summary> public void SaveConfiguration() { try { ConfigDoc?.Save(ConfigFileName); } catch (Exception) { } }
private void InitializeConfigFile() { // First add in the root node XmlElement rootNode = ConfigDoc.CreateElement("Configuration"); ConfigDoc.AppendChild(rootNode); // Then prepare the XML declaration XmlDeclaration xmlDeclaration = ConfigDoc.CreateXmlDeclaration("1.0", "UTF-8", null); ConfigDoc.InsertBefore(xmlDeclaration, rootNode); // Now, the Polygon KML polygon file location XmlElement kmlFileElement = ConfigDoc.CreateElement("PolygonKmlFileLocation"); XmlText kmlFileField = ConfigDoc.CreateTextNode(string.Empty); kmlFileElement.AppendChild(kmlFileField); rootNode.AppendChild(kmlFileElement); // The Bus Stop XML raw file XmlElement busXmlFileElement = ConfigDoc.CreateElement("BusStopXmlFileLocation"); XmlText busXmlFileField = ConfigDoc.CreateTextNode(string.Empty); busXmlFileElement.AppendChild(busXmlFileField); rootNode.AppendChild(busXmlFileElement); // The Route-Stop XML raw file GenerateRouteStopXmlNode(); // The bus route details XML raw file GenerateBusRouteDetailsXmlNode(); // Everything should be ready. // Save the config first. ConfigDoc.Save("config.xml"); }