public static string writeXml(object value) { string str; using (MemoryStream memoryStream = new MemoryStream()) { XmlWriterSettings xmlWriterSetting = new XmlWriterSettings() { Encoding = new UTF8Encoding(false), ConformanceLevel = ConformanceLevel.Document, Indent = true }; using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream, xmlWriterSetting)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); xmlWriter.WriteStartElement("plist"); xmlWriter.WriteAttributeString("version", "1.0"); Plist.compose(value, xmlWriter); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); xmlWriter.Close(); str = Encoding.UTF8.GetString(memoryStream.ToArray()); } } return(str); }
private static void composeArray(List <object> value, XmlWriter writer) { writer.WriteStartElement("array"); foreach (object obj in value) { Plist.compose(obj, writer); } writer.WriteEndElement(); }
private static void writeDictionaryValues(Dictionary <string, object> dictionary, XmlWriter writer) { writer.WriteStartElement("dict"); foreach (string key in dictionary.Keys) { object item = dictionary[key]; writer.WriteElementString("key", key); Plist.compose(item, writer); } writer.WriteEndElement(); }