我有一个程序将从我的服务器上的 .plist 接收其中显示的信息。不过,我将为 PC 制作此程序,并且我将使用 Java 来完成此操作。 Plist 文件不是传统的 XML,因此常见的 XML 解析库不起作用。我找不到任何 plist 特定的解析器,所以我不知道如何继续。我认为我的选择是:
a) 为 plist 文件找到这样的解析器
b) 使用常规 XML 解析器进行解决方法
c) 更改程序从中获取数据的文件(不可取)
是否有其他人有过相关经验Objective-C 以外的语言的 plist?
I have a program that is going to be receiving info displayed in it from a .plist on my server. However, I am going to be making this for PC, and I'm using Java to do so. Plist files aren't conventional XML, so common XML parsing libraries don't work. I can't locate any plist specific parsers, so I am lost on how to continue. The way I see it my options are:
a) Locate such a parser for the plist file
b) Make a workaround using a regular XML parser
c) Change the file the program gets its data from (undesirable)
Has anyone else had any experience with plists in languages other than Objective-C?
发布评论
评论(3)
正如 @Jochen Bedersdorfer 所指出的,
.plist
文件是 XML,具有格式良好的plutil
将它们从二进制转换为文本形式。附录:在评论中,您问
未必。以下是有关该主题的一些历史。
As @Jochen Bedersdorfer notes,
.plist
files are XML with a well-formed DTD. Useplutil
to convert them from binary to text form.Addendum: In a comment, you asked
Not necessarily. Here's some history on the subject.
为了消除任何混淆:
plist
文件可以是 XML 形式,也可以是二进制形式。xmllint
。描述
。key
和string
。创建包含这些对的哈希。然后根据key得到字符串。To remove any confusion:
plist
file can be either in XML or in binary form.xmllint
against an XML plist.<dt>title</dt><dd>description</dd>
.plutil
on OS X. Convert it to XML before sending it over the network.key
andstring
. Make a hash containing these pairs. Then you get the string based on the key.dd-plist 可能会有所帮助。
dd-plist might be helpful.