Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nkeung

macrumors newbie
Original poster
Jul 25, 2011
1
0
I have trouble displaying text using hpple xml paser. I want to display the text inside the cdata section and this is the query that I am using

//rss/channel/item[1]/title/text()

It's just reutrn nil as a result.

<title>
<![CDATA[Envious at Envie! 50% off anything you want, anytime you want!]]>
</title>

I am using hpple library for iphone xcode. Here is my code:

NSData *urlData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[@"http://www.twangoo.com/userfiles/rss/rss_hong-kong.xml" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:urlData];

NSArray *title = [xpathParser search:mad:"//rss/channel/item[1]/title/text()"];

TFHppleElement *element2 = [title objectAtIndex:0];

NSString *titleString = [element2 content];

NSLog(@"@%", titleString)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.