Parsing SO RSS feed using TouchXML, no <entry> tags

I am trying to parse a Stack RSS feed for a specific question: stack overflow

For this, I use the TouchXML library. The problem seems to be in the following code:

CXMLDocument *parser = [[CXMLDocument alloc] initWithData:sourceData options:0 error:nil];
NSArray *allEntries = [parser nodesForXPath:@"//entry" error:nil];
NSLog(@"Found entries: %d",[allEntries count]); //Returns 0

The NSLog statement must return the number of all entries in the feed. In this case, it should be "3", the problem is that it returns 0.

I found that this piece of code works:

CXMLDocument *preParser = [[CXMLDocument alloc] initWithData:sourceData options:0 error:nil];
NSString *sourceStringUTF8 = [preParser XMLString];
[preParser release];

CXMLDocument *parser = [[CXMLDocument alloc] initWithData:[sourceStringUTF8 dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
NSArray *allEntries = [parser nodesForXPath:@"//entry" error:nil];
NSLog(@"Found entries: %d",[allEntries count]); //Returns 3, which is ok

But using it seems hacked (perhaps it is) and introduces several other sporadic errors.

As far as I know, the correct Xpath expression. I checked it using this page .

Can someone help me with this problem or point me in the right direction.

Thank.

+3
2

. - xml, TouchXML ( ).

, , , .

-

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<html>

xPath.

+2

, error nodesForXPath:error, , ? , allEntries nil ?

0

Source: https://habr.com/ru/post/1731261/


All Articles