考虑以下 C# 代码:
XmlTextWriter writer = new XmlTextWriter(pathFichier, null);
writer.WriteStartDocument();
writer.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
writer.WriteStartElement("plist");
writer.WriteAttributeString("version", "1.0");
writer.WriteFullEndElement(); // plist
writer.Close();
PList 文档类型通常是:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
上面的代码在 doctype 字符串的末尾添加了一个空子集:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"[]>
末尾的“[]”与 iOs 的解析有关。
如何使用 XmlTextWriter 摆脱它?
我应该重新打开文件并删除“[]”吗?