iphone - TFHpple - getting element HTML without element's tags? -


i'm parsing html , need innerhtml of <body />. i'm doing way:

tfhpple *doc = [[tfhpple alloc] initwithhtmldata:[nsdata datawithcontentsoffile:sectionfilepath]]; tfhppleelement *body = [doc searchwithxpathquery:@"//body"][0];  nsstring *bodyhtml  = body.raw; 

however returns:

<body>stuff inside body</body> 

instead of just:

stuff inside body 

question: there way purely inner html of element, excluding own tags?

i came method, feel i'm reinventing wheel here. method quite slow.

tfhppleelement *child; for(int = 0; i<body.children.count; i++){     child = (tfhppleelement*)body.children[i];      if(child.raw != nil) [bodyhtml appendstring:child.raw];     else if(child.content != nil) [bodyhtml appendstring:child.content]; } 

try this...

nsurl *url = [nsurl urlwithstring: url_here]; nsdata *htmldata = [nsdata datawithcontentsofurl:url];  tfhpple *parser = [tfhpple hpplewithhtmldata:htmldata];  nsstring *xpathquerystring = @"//body"; nsarray *nodes = [parser searchwithxpathquery:xpathquerystring];  (tfhppleelement *element in nodes) {      lable.text = [[element firstchild] content]; } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -