Quick way to get an NSDictionary from an XML NSData representation?
Posted
by dontWatchMyProfile
on Stack Overflow
See other posts from Stack Overflow
or by dontWatchMyProfile
Published on 2010-06-17T11:01:16Z
Indexed on
2010/06/17
11:03 UTC
Read the original article
Hit count: 724
I've loaded an XML file as NSData into memory and parse over the elements using NSXMLParser. Although it works, it's a very ugly and hard to maintain code since there are about 150 different elements to parse.
I know there are nice third-party solutions, but I want to keep it with the iPhone SDK for purpose of practice and fun.
So I thought: Why not convert that XML file into an NSDictionary? Having this, I could use fast enumeration to go over the elements.
Or is it just the same amount of ugly code needed to parse and process an XML right away with NSXMLParser?
Would I build up an NSDictionary for every found node in the XML and create a huge one, containing the whole structure and data? Or is there an even simpler way?
© Stack Overflow or respective owner