Using NSXMLParser with CDATA

前端 未结 2 1502
说谎
说谎 2020-12-05 16:04

I\'m parsing an RSS feed with NSXMLParser and it\'s working fine for the title and other strings but one of the elements is an image thats like



        
相关标签:
2条回答
  • 2020-12-05 16:30

    You can use

    - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock
    {
        NSString *someString = [[NSString alloc] initWithData:CDATABlock encoding:NSUTF8StringEncoding];
    }
    
    0 讨论(0)
  • 2020-12-05 16:43

    The point of CDATA is that anything within it is not treated as part of the XML document. So if you have tags in CDATA the parser will ignore them.

    I'm guessing this CDATA is in the description element. So you'll need to extract the tags from the "description" element, either manually or via another instance of a parser.

    0 讨论(0)
提交回复
热议问题