views:

264

answers:

2

What's the best way to load and process a "two-level nested" plist file using MonoTouch? I have a plist file with data (structurally) similar to the following:

- USA
--- New York
--- Chicago
- UK
--- London
--- Edinburgh
- France
--- Paris
--- Lyon

I have Obj C samples that use NSDictionary and NSArray, but I'd like to get it into a standard C# data structure as quickly as possible. I haven't been able to locate any complete examples.

A: 

You could use the .NET System.Xml libraries to read it, as .plist is simply an XML file. You have the choice of using XPath, looping with XmlDocument/XmlNode, or maybe even LINQ-To-XML (I'm not sure if this is supported on Monotouch).

You can find a lot of XML reading examples out there - XmlReader would be the fastest as it's forward only.

Chris S
A: 

I was in a similar situation and I tried a lot of different options (including LINQ to XML). I ended up doing the following:

  1. Convert plist to cleaner XML using XSLT
  2. Use XmlSerializer to load into strongly-typed classes

That seemed to be the best solution. Good luck!

Bryant Hankins