3

I'm looking for the best way to parse XML on iOS. There seem to be SO many ways to do this, so many different examples. Specifically, I want to send a request to a weather service, then extract the weather from the XML response.

If you could point me in the right direction and hopefully someone else will also find this useful.

W Dyson
  • 4,604
  • 4
  • 40
  • 68

2 Answers2

5

If the xml document is small to medium sized, then NSXMLParser is the way to go: NSXMLParser

ennuikiller
  • 46,381
  • 14
  • 112
  • 137
  • 1
    +1. I was just about to post something similar. It's worked very well for me in my projects, and if you have experience with event based parsers with other languages, it will be familiar. – Greg Nov 08 '10 at 20:23
  • Thanks guys. I haven't really done anything like this before. Wish me luck. If anyone has any other suggestions, post away! – W Dyson Nov 08 '10 at 20:27
  • 1
    When using NSXMLParser, you need to use a property to identify which node of the XML you're on. As you keep iterating through nodes, when you come to the right one you can then get the data inside. It's semi-convoluted, but there is an example tutorial I found on Google when looking for XML parsing tutorials for Cocoa. The author used an XML of a collection of Harry Potter books for her example. – Daddy Nov 08 '10 at 21:11
0

Check out this one - How To Choose The Best XML Parser for Your iPhone Project

the.evangelist
  • 488
  • 5
  • 18