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 01-30-2012, 07:08 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 6
doctorclod is on a distinguished road
Default XML-Based Application

Hi everyone,

I'm a long-standing web developer and have recently switched to iPhone development. I am by no means a guru but I know my way around Objective-C.

I am currently working on a project which involves parsing XML. I have created a simple RSS reading application in the past, but my current project is giving me a few headaches. While the project is primarily going to be used by me personally, I want to plan the data model carefully so that in the future I could expand on it with an aim to producing a commercial release.

Effectively, I am developing an application which can parse an XML file representing, for example, study notes. Such a file would resemble the following:

Code:
<subject>
	<title>Dogs</title>
	<topic>
		<title>Yorkshire Terriers</title>
		<section>
			<title>What is a Yorkshire Terrier?</title>
			<text>A Yorkshire terrier is a breed of dog.</text>
			<text>I like dogs, they're nice.</text>
			<image>
				<path>file.jpg</path>
				<title>An image</title>
				<caption>This is the caption</caption>
			</image>
			<graph>
				<axes>0-10,0-10</axes>
				<point>0,0</point>
				<point>10,10</point>
			</graph>
			<subsection>
				<title>Training Yorkshire Terriers</title>
				<text>Yorkshire terriers are easy to train.</text>
				<blist>
					<item>This is the first item in a bulleted list.</item>
					<item>This is the second item in a bulleted list.</item>
				</blist>
				<nlist>
					<item>This is the first item in a numbered list.</item>
					<item>This is the second item in a numbered list.</item>
				</nlist>
			</subsection>
		</section>
	</topic>
</subject>
The problem is that within a single 'section' or 'subsection' tag, I would like the rest of the data to be displayed in any order. While the 'title' tag is required, any number of 'text' tags (which would approximately equate to paragraphs), 'image' tags, graphs and lists could be displayed. For example, some sections will not contain any text, only images. Some sections will contain four paragraphs of text, others ten paragraphs etc..

My initial thoughts were to create a 'section' class (subject of NSObject), and parse the XML and create all the child objects on the fly (UILabels, UIImages etc.). Is this a viable approach? Or should I be doing something else entirely?

I am aware that this data could be very easily be recoded as HTML and displayed in a UIWebView, but I would like to avoid this as much as possible, since down the line I would like to add user interaction to individual objects, and I fear that lumping everything together within a web view would prevent me from doing so.

Sorry for such a long post!

Clovis
doctorclod is offline   Reply With Quote
Old 01-30-2012, 08:52 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 6
doctorclod is on a distinguished road
Default

Bump. Just kidding.

I feel I have found a potential solution with the help of this tutorial: Make NSXMLParser your friend.. codesofa - chaotic. pragmatic. smart(***). - so will get to work on that. But if anyone has anything to contribute (for example if you think I'm setting myself up for a fall later on) please let me know! But for now, looks like I've got work to do!

Clovis
doctorclod 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: 420
17 members and 403 guests
Atatator, chiataytuday, condor304, dre, FrankWeller, imac74, ipodphone, jeroenkeij, kukat, LunarMoon, mraalex, n00b, PowerGoofy, QuantumDoja, Retouchable, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,675
Threads: 94,124
Posts: 402,909
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Retouchable
Powered by vBadvanced CMPS v3.1.0

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