Plist contains the "&" character
Asked Answered
V

2

14

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?

Vance answered 21/9, 2010 at 6:28 Comment(0)
G
29

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.

Giess answered 21/9, 2010 at 6:31 Comment(3)
i'm directly modifying the xml <Code> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <plist version="1.0"> <dict> <key><![CDATA[a&amp;b]]></key> <array> <string><![CDATA[a&amp;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
R
0

If you insert the values when open plist file as property list it would do it automatically.

Reverence answered 28/3, 2017 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.