Reputation: 155
I would need some help in python. I'm new in python. I used to program a lot in Objective-C.
<?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>1</key>
<string>Object One</string>
<key>2</key>
<string>Object Two</string>
<key>3</key>
<string>Object Three</string>
</dict>
</plist>
If I load it in Objective-C , I can directly get the dictionary as a NSDictionary.
So my question is: how can I do that easily in Python. I found some stuff using parsers such as lxml. I managed to load the data but I was not able to get a dictionary with only the keys and the values. I searched lot on the internet but wasn't able to find something suitable. Does anyone has an idea or an advice?
I tried this: http://code.activestate.com/recipes/410469-xml-as-dictionary/ but I didn't manage to make it work.
In advance, Thank you very much!
Upvotes: 1
Views: 302
Reputation: 8942
Use plistlib: http://docs.python.org/dev/library/plistlib.html
pl = readPlist(pathOrFile)
print(pl["1"])
Upvotes: 1