Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7433927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:45:04+00:00 2026-05-29T09:45:04+00:00

I am converting an iOS app to WP7. What I would like to do

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:45:05+00:00Added an answer on May 29, 2026 at 9:45 am

    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:

    public class PropertyListParser
    {
        public IDictionary<String, Object> Parse(string plistXml)
        {
            return Parse(XDocument.Parse(plistXml));
        }
    
        public IDictionary<String, Object> Parse(XDocument document)
        {
            return ParseDictionary(document.Root.Elements("plist")
                .Elements("dict")
                .First());
        }
    
        private IDictionary<String, Object> ParseDictionary(XElement dictElement)
        {
            return dictElement
                .Elements("key")
                .ToDictionary(
                    el => el.Value,
                    el => ParseValue(el.ElementsAfterSelf("*").FirstOrDefault())
                );
        }
    
        private object ParseValue(XElement element)
        {
            if (element == null)
            {
                return null;
            }
    
            string valueType = element.Name.LocalName;
    
            switch (valueType)
            {
                case "string":
                    return element.Value;
                case "dict":
                    return ParseDictionary(element);
                case "true":
                    return true;
                case "false":
                    return false;
                default:
                    throw new NotSupportedException("Plist element not supported: " + valueType);
            }
        }
    }
    

    Here’s an example of how to use it (based on your example):

    var parsedPlist = new PlistParser().Parse(Plist);
    
    var section0 = (IDictionary<string, object>)parsedPlist["section0"];
    
    var key0 = (IDictionary<string, object>)parsedPlist["key0"];
    
    string type = (string)key0["type"];
    bool filter = (bool)key0["filter"];
    

    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.

    // I'm not sure what your domain object is, so please rename this
    public class ConfigEntry
    {
        public string Name { get; set; }
        public string Type { get; set; }
        public bool Filter { get; set; }
    }
    
    public class ConfigEntryLoader
    {
        private PropertyListParser plistParser;
    
        public ConfigEntryLoader()
        {
            plistParser = new PropertyListParser();
        }
    
        public ICollection<ConfigEntry> LoadEntriesFromPlist(string plistXml)
        {
            var parsedPlist = plistParser.Parse(plistXml);
    
            var section0 = (IDictionary<string, object>)parsedPlist["section0"];
    
            return section0.Values
                .Cast<IDictionary<string,object>>()
                .Select(CreateEntry)
                .ToList();
        }
    
        private ConfigEntry CreateEntry(IDictionary<string, object> entryDict)
        {
            // Accessing missing keys in a dictionary throws an exception,
            // so if they are optional you should check if they exist using ContainsKey
            return new ConfigEntry
            {
                Name = (string)entryDict["name"],
                Type = (string)entryDict["type"],
                Filter = (bool)entryDict["filter"]
            };
        }
    }
    

    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.

    ICollection<ConfigEntry> configEntries = new ConfigEntryLoader()
        .LoadEntriesFromPlist(plistXml);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built an iOS app which I would now like to test converting
Is converting a file to a byte array the best way to save ANY
In iOS,I would like to include both a delegate for the flipsideView (from a
Im making on an ios app and currently working to get cell deletion from
Apple's iOS SDK use a modified version of pngcrush for converting png files in
For converting a integer into an enum (out of a json file), I declared
I have an app that struggles to perform well on iOS 5 running on
I'm currently working on converting an Android app I built natively as an iPhone
I am converting over to iOS 5 and storyboards. When I have a table
Has anyone had luck converting and using jpeg2000 on the ios? I am writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.