I have trouble working with xml query. Below is the xml document. All I need to do is to display the text inside the cdata section. I wrote this query: /item/title/text()
, but it crashed and doesn't work.
<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:@"//rss/channel/item[1]/title/text()"];
TFHppleElement *element2 = [title objectAtIndex:0];
NSString *titleString = [element2 content];
NSLog(@"@%", titleString)
It returns nil.