iphone - How to parse html in iOS to get all its content along with tag name? -
i tried parse html data using tfhpple
mentioned below
tfhpple *tutorialsparser = [tfhpple hpplewithhtmldata:tutorialshtmldata]; nsstring *tutorialsxpathquerystring = @"//body"; nsarray *tutorialsnodes = [tutorialsparser searchwithxpathquery:tutorialsxpathquerystring];
after done above step getting tutorialsnodes array contain data.
want find each tag in content.
need tag identified image or text etc.
don't understand how it.
something this, perhaps?
... (tfhppleelement *element in tutorialsnodes) { [self handleelement:element]; } ... } - (void)handleelement:(tfhppleelement *)element { (tfhppleelement *child in element.children) { nsstring *textinsidethechildelement = child.content; if ([child.tagname isequaltostring:@"img"]) { nsstring *sourceurl = child.attributes["src"]; } else { [self handleelement:child]; } } }
Comments
Post a Comment