I'm having a .plist file which has some values with the "&" sign, for example "M&I". When I save the file to the document folder and load it from there, I'm getting an empty dictionary. Any idea to how to fix this issue?
Plist contains the "&" character
Asked Answered
If you are directly modifying the XML file, you have to escape certain characters - &
should be escaped using the XML entity &
. If you use the editors, this should be done automatically for you.
If you use CDATA
sections instead, you don't have to escape the characters.
i'm directly modifying the xml <Code> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <plist version="1.0"> <dict> <key><![CDATA[a&b]]></key> <array> <string><![CDATA[a&b]]></string> <string>zip path</string> <string>zip name</string> <string>date</string> </array> </dict> </plist> </Code> but im getting an empty dictionary when read the list, –
Vance
even if i remove the CDATA i can't read the data to dictionary,when i remove the "&" everything works fine. –
Vance
@Sam: Actually that loads for me. You only need to use either
CDATA
or escapes though. –
Giess If you insert the values when open plist file as property list it would do it automatically.
© 2022 - 2024 — McMap. All rights reserved.