private static void ExportXml2(ForecastXmlData dataList) { //List<ThresholdData> converted = ConvertTo(dataList); string filePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + "forecast_attributes22.xml"; string tryFile = filePath; using (StreamWriter writer = new StreamWriter(tryFile, false, Encoding.Unicode)) { XmlSerializer serializer = new XmlSerializer(typeof(ForecastXmlData)); serializer.Serialize(writer, dataList); } }
public static void DoTest() { // export xml //ExportXml(); // parse xml file //ParseXml(); ForecastXmlData xmlData = new ForecastXmlData(); xmlData.data = new List <ForecastData>(); xmlData.data.Add(new ForecastData() { Name = "current", Temperature = "15", Unit = "c", High = "20", Low = "10", Humidity = "70" }); xmlData.data.Add(new ForecastData() { Name = "monday", Temperature = "16", Unit = "c", High = "21", Low = "11", Humidity = "65" }); xmlData.data.Add(new ForecastData() { Name = "tuesday", Temperature = "17", Unit = "c", High = "22", Low = "12", Humidity = "61" }); ExportXml2(xmlData); }