Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-05-2010, 06:06 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 3
tribeca is on a distinguished road
Default Parse xml data and assign element values dynamically to object

Im stuck with this:
I need to fetch xmldata from a website, parse it and bring it into a more accessible form. I've read a few tutorials/guides about how to parse xml and they more or less all have the same approach: Creating an instance of NSXMLParser and the delegates assign the parsed values to an object.

Though this is basically working for me, all the sample code I saw seemed not very generic to me. There is always just one target object and there are a lot of if/else statements matching the xml elements with hard coded strings when assigning the values to the object properties. Since I need to get data from different xml files and store each in a different object this would be quite hard to maintain.

Luckily the name of the xml elements match the object properties so I can dynamically check whether the corresponding property exists and assign it if so. But the different objects are driving me crazy. I tried several things but could not get anything to work. Does I really have to implement all the possible classes and create an instance for the suiting one (according to a passed class name or something like that)? My inital idea was to pass the object to the xmlparser and let the parser assign the values. But as I said I couldn't get this working.

If someone has an idea how to make this work (or maybe a complete different approach) I would really appreciate it if he could describe it here or give me some hint into the right direction.

Thanks!

Last edited by tribeca; 12-06-2010 at 06:40 AM.
tribeca is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 388
7 members and 381 guests
chemistry, daudrizek, HemiMG, jeroenkeij, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:55 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0