views:

196

answers:

2

I'm looking to retrieve an XML document from a private API, then parse it into a table view.

I've looked through a few articles but I can't find anything that has helped me fully.

Does anyone have any articles, tutorials, examples, etc that can help me out?

Thanks in advance!

+2  A: 

I'd say this can be split into two problems:

First: Parsing XML

There are two ways to do this: some like event-driven XML; I strongly prefer tree-based XML. You should read a little into each of those tutorials and see which makes the most sense to you; I bet you'll prefer one of them based on your past programming experiences.

Second: Using Table Views

Once you've parsed your XML into some sort of dictionary or custom object, you'll need to display that object's information in a table view. For that, I suggest bindings. This CocoaDevCentral tutorial explains how to use bindings to display information in an NSTableView. (It even covers using multiple table views to create a Mail.app-like interface, which you may or may not find useful.)

Or... An Alternative, Less Flexible Method

In the guide for tree-based XML, there's a section on binding NSXMLDocument objects directly to table views. If you're sure that you'll be modifying the XML in such a direct way (for example, if you were writing, say, an XML editor!), then maybe that's a good idea, and you should check out this sample project. Otherwise, it'll be inflexible and you'll have to change it soon as you add features.

Good luck!

andyvn22
A: 

I had a similar problem recently and settled on the TouchXML library http://code.google.com/p/touchcode/wiki/TouchXML It wraps the NSXML cluster of classes and is based on the commonly available Open Source libxml2 library. The TouchXMLHowTo page http://code.google.com/p/touchcode/wiki/TouchXMLHowTo was useful in getting started. With TouchXML you can use XPath, and I found this most similar to what I had done in Java.

Rob Wright
I think (and I'm not familiar with TouchXML, so don't trust me blindly) that TouchXML is meant to be a substitute for NSXML on platforms that don't have NSXML. (For example, the iPhone! What the heck!?) It implements the same methods as NSXML, but is missing some and is read-only. So I definitely wouldn't recommend it for OS X programming, where you have access to the real deal. :)
andyvn22