xml parser problem

Discussion in 'iOS Programming' started by nkeung, Jul 25, 2011.

  1. nkeung macrumors newbie

    Jul 25, 2011
    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:mad:"//rss/channel/item[1]/title/text()"];

    TFHppleElement *element2 = [title objectAtIndex:0];

    NSString *titleString = [element2 content];

    NSLog(@"@%", titleString)

Share This Page