views:

568

answers:

2

I have an XML documment that I want to load for the iPhone, do I need to convert it to a plist first ? if so how ?

The xml document has the following code ( for 1 chapter)

<toolTipsBook>
−  <chapter index="1" name="Chapter Name">
<line index="1" text="line text here"/>
<line index="2" text=" line text here "/>
<line index="3" text=" line text here "/>
<line index="4" text=" line text here "/>
<line index="5" text=" line text here "/>
<line index="6" text=" line text here "/>
<line index="7" text=" line text here "/>
</chapter>

How can I tell xcode to display chapter 1 line 1 and then leave space under that for my comment ( a seperate xml document) for chapter l line 1 directly under it.

The idea is that I'll have this control for all the chapters in the data I'm loading.

If you have a little time I'd really appreciate it if you could give some sample could to please show what you mean.

Thanks guys,

A: 

Have you looked at NSXMLParser?

It's purpose is to parse the XML into a data structure.

Then you display that data structure using whatever user interfaces you feel are appropriate (such as a UITableView).

Epsilon Prime
+3  A: 

You can add the XML file into resources of your application.

You do that by dragging to resources directory in Xcode, and in popup select copy file to project.

When your application run you open the file by referring to it by it's name, read in the XML, parse it with NSXMLParser and extract required data. No need to convert to plist.

This assumes that the xml data is static and you don't indent to update and save it.

stefanB
Of course you would then read the data and maybe display it with UITableView, providing data source for the table, maybe a NSDictionary of data read from XML file or similar.
stefanB
Would it be a better idea to use an SQL dump version of that data I have , and use SQLite?
Dave
If you're planning to store the entire book you'd probably be better off cooking the database into your app (yes, using `SQLite`) -- why parse something you don't really need to?
Epsilon Prime
How would I go about doing this? just tell xcode to load a database?
Dave
I'm not sure if you need sqlite, maybe you can parse the xml once and retain reference to it then use xpath to retrieve required fields.
stefanB