4

How can I parse an HTML file under iOS? Any tutorials or sample code available?

Felixyz
  • 19,053
  • 14
  • 65
  • 60
Abhijeet Barge
  • 562
  • 5
  • 21
  • You need to parse it to manage the data contained in the html page or you just need to display the html page? – lomanf Feb 09 '11 at 06:51
  • @lomanf I need to parse data from that html file and display it in my own view like table view. – Abhijeet Barge Feb 09 '11 at 06:54
  • 2
    Please go through this link http://stackoverflow.com/questions/405749/parsing-html-on-the-iphone – Mihir Mehta Feb 09 '11 at 07:10
  • 2
    OK then try to have a look here http://stackoverflow.com/questions/405749/parsing-html-on-the-iphone there's a nice example using the "hpple" library – lomanf Feb 09 '11 at 07:10

2 Answers2

2

Check out NSXMLParser. It's Apple's class for parsing XML documents. Should be a good start, if you know something about the format of the document in advance

Jeremy Massel
  • 2,257
  • 18
  • 22
1

Use XPathQuery to parse HTML or XML conveniently

  1. Google XPathQuery for iphone
  2. download XPathQuery.h and XPathQuery.m
  3. include both files in the project.
  4. Use the following method to parse HTML.
NSArray *PerformHTMLXPathQuery(NSData *document, NSString *query);
pradeepa
  • 4,104
  • 5
  • 31
  • 41