I am converting an iOS app to WP7. What I would like to do is use the plist file I created for the iOS app in my WP7 app without making any changes to it. I tried using the libraries from here http://codetitans.codeplex.com/ but I was only able to parse down one level, my plist has multiple levels. Here is example of the plist file I’m trying to parse:
<?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>section0</key>
<dict>
<key>key0</key>
<dict>
<key>name</key>
<string>Title</string>
<key>type</key>
<string>text</string>
<key>filter</key>
<false/>
</dict>
<key>key1</key>
<dict>
<key>name</key>
<string>Season</string>
<key>type</key>
<string>text</string>
<key>filter</key>
<false/>
</dict>
</dict>
</dict>
Part 1: What you asked for
WP doesn’t currently have very good support for dynamic types so while parsing it won’t be difficult, consuming it will be ugly.
This class will parse the PList using LINQ to XML:
Here’s an example of how to use it (based on your example):
Part 2: What you probably need
Having said that, actually writing code that consumes it in this way would be pretty ugly. Based on your schema, I’d say that the following is actually what your application needs.
Now when you use
ConfigEntryLoader, you get a list of ConfigEntry objects which will make your code much easier to maintain that passing around dictionaries.