0

I have a html file that has something similar to

<div @class = 'myclass' element1 element2 element3> 

How do I parse it to fetch element1, elemnet2 and element3?

I am using Hpple for iOS.

I am using query like

NSString *elementsXpathQueryString = @"//div[@class='myclass']/a";

but it doesn't work out.

TIA

iOSDev
  • 3,617
  • 10
  • 51
  • 91
  • 1
    That doesn't look like valid HTML. – Kreiri May 05 '14 at 13:47
  • Hmm well, many sites are using this format. And I need to parse it to display on iOS. – iOSDev May 05 '14 at 14:22
  • Have you tried getting the keys of `TFHppleElement`s `attributes` dictionary? – HAS May 05 '14 at 16:55
  • yes but the elements list keep on changing with every html response. It can be e1, e2, e3 initially but it may be e1 only with next response. How to fetch these values? – iOSDev May 05 '14 at 20:29
  • Please see my edits for query string. – iOSDev May 05 '14 at 20:31
  • Those aren't elements; they're attributes. as HAS said those are accessible via the "attributes" method as an NSDictionary object. The "count" method for that class will return you the number of attributes in the dictionary. – geowar May 06 '14 at 15:42
  • Don't understand whether have `
    ` or `
    elem0 elem1
    ` - how to get data will depend on which!
    – cate Oct 28 '14 at 13:04

0 Answers0