iphone - Unable to obtain content from website using Hpple -
iphone - Unable to obtain content from website using Hpple -
i trying parse website using hpple. successful tag doesn't seem work on other tag. please advice.
this code used.
nsdata *htmldata = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:@"http://www.mywebsite.com/"]]; tfhpple *xpathparser = [[tfhpple alloc] initwithhtmldata:htmldata]; nsarray *elements = [xpathparser search:@"//tr/td"]; tfhppleelement *element = [elements objectatindex:0]; nsstring *mytitle = [element content]; nslog(mytitle); mlabel.text = mytitle; [xpathparser release]; [htmldata release]; this website source code trying parse from.
<tr><td bgcolor="#f7f7f7" align="left" width="200" valign="middle" class="font1">title of speech</td><td bgcolor="#f7f7f7" align="left" width="150" valign="middle" class="font3">speaker name</td><td bgcolor="#f7f7f7" align="left" width="150" valign="middle" class="font3">date , time</td><td bgcolor="#f7f7f7" align="center" width="50" valign="middle" class="font3"><a href=""><a href="http://speech.mp4" target="blank"><img src="/templates/public/images/mp4_300.png" border="0" /></a></a></td i intending parse out speech title, speaker, date , time , name of mp4 file. homecoming empty string outlet label. please advice.
regards, des
late maybe useful others:
use
nsstring *mytitle = [element text]; instead of content
i used hpple getting <title>-tag of websites. content empty not text.
iphone html-parsing
Comments
Post a Comment