View Full Version : xml parser problem

Jul 25, 2011, 04:18 AM
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


It's just reutrn nil as a result.

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

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:@"//rss/channel/item[1]/title/text()"];

TFHppleElement *element2 = [title objectAtIndex:0];

NSString *titleString = [element2 content];

NSLog(@"@%", titleString)