0

I am trying to make an app in objective-c that will parse an xml document like so using XMLReader (https://github.com/amarcadet/XMLReader):

    <episodes>
  <title>title title title</title>
  <link>link link link</link>
  <description>description description description</description>
  <item>
    <title>title title title</title>
    <link>link link link</link>
    <description>description description description</description>
  </item>
  <item>
...
</episodes>

I honestly have no idea how I'm supposed to do this. I have already imported the two files included in the zip, but when I try to call

NSData *data = http://link.to.xml/file // some data that can be received from remote service
NSError *error = nil;
NSDictionary *dict = [XMLReader dictionaryForXMLData:data 
                                             options:XMLReaderOptionsProcessNamespaces 
                                               error:&error];

it crashes giving me a SIGABRT on main thread. Can anyone help with this??? Also, how do I get the resulting NSArray or NSDictionary into a table view?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
TheMacMini09
  • 11
  • 1
  • 1

2 Answers2

1

Check the post by Troy http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/

Also, There are plenty of examples out there which can get you started. Check out the answers here for a similar question: Xml parsing in iOS tutorial always good idea to code through some tutorials before actual implementation.

Community
  • 1
  • 1
Obj-Swift
  • 2,802
  • 3
  • 29
  • 50
1

You can't just write:

NSData *data = http://link.to.xml/file // some data that can be received from remote service

To get data from a URL. At least use something like NSData's +dataWithContentsOfURL:, except that it going to be synchronous and not very user friendly.

I don't think your problem is the data parsing at this point; you're having trouble getting the data which is a whole subject in itself, apart from parsing XML. You could start with the URL Loading System Programming Guide which will show you how to get data properly.

Abizern
  • 146,289
  • 39
  • 203
  • 257