编辑.plist文件 - 是否允许作为字符串使用单引号?

And*_*ord 4 xml macos plist cssedit

特别是,我正在编辑CSSEdit的AutoCompletion.plist文件(如果这甚至很重要).

我的问题是,是否有任何需要转义STRING元素的角色?空间?报价?

编辑:为了清楚,我没有使用CSSEdit来编辑文件 - 而是文件是CSSEdit包的一部分.我正在使用TextMate编辑文件(虽然"Property List Editor.app"是另一种选择),它是XML格式.这是AutoCompletion.plist文件的一个片段:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>font-family</key>
<array>
    <string>Arial</string>
    <string>Helvetica</string>
    <string>Georgia</string>
    <string>serif</string>
    <string>sans-serif</string>
    <string>cursive</string>
    etc...
Run Code Online (Sandbox Code Playgroud)

我想添加空格和单引号的STRING,例如:

<string>Georgia, Times, 'Times New Roman', serif</string>
Run Code Online (Sandbox Code Playgroud)

但是当我编辑文件时,CSSEdit会变得混乱

Bri*_*ter 16

如果您使用某种文本编辑器编辑XML plist,则需要像在任何XML中一样转义字符.要注意的基本字符是:

<(小于),转义为<

>(大于),转义为>

&(和号),逃脱& amp;

'(撇号),逃脱'

"(引号),逃脱为"

所以在你的例子中,你会想要

<string>Georgia, Times, &apos;Times New Roman&apos;, serif</string>

您还可以使用Apple的Property List Editor等工具,这些工具包含在他们的免费Xcode开发工具中,或者使用像PlistEdit Pro这样的第三方产品,这两种产品都会为您提供所有角色转移功能.