views:

124

answers:

4

basically im looking for something that will just turn xml into an nsdictionary hierarchy.

A: 

On the iPhone, the way to do XML parsing is to use the NSXMLParser class, which takes a delegate (a.k.a. visitor) object of type NSXMLParserDelegate which gets invoked as different parts of the XML tree are visited. So, you can create a delegate that stores away the information into a dictionary. That said, most likely you won't care about everything in the XML that you parse, which is exactly why these parsing mechanism exists; you can create delegate that stores just the bits you want, which is faster and more memory efficient than adding a new dictionary entry for everything even if you never use it.

Michael Aaron Safyan
I 100 percent hear what you're saying but if I want to just use a quick and dirty xml parser for a small piece of xml, that I don't have to dive into, there isn't really much out there then? I guess this brings up another question which is: is JSON just much more elegant of a solution why should we have to reinvent the wheel each time we go to start parsing xml, from the outside looking in it seems like a waste of my time but, I also hear what you're saying in that hey just parse what you need and ignore the rest. if it's that much of a pain to parse XML is JSON becoming the new hawtness?
nickthedude
A: 

Here is tutorial with sample code explaining parsing a xml with NSXMLParser and save it as a array of dictionaries and dispaled it in a tableview.Hope this will be help you.

All The Best.

Warrior
+1  A: 

Hey Nick, I wrote an XML to NSDicitonary converter you might find useful:

http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/

Troy Brant
you rock dude!!
nickthedude