iphone - Parsing SO RSS feed using TouchXML, no <entry> tags found -
I am trying to parse a stack overflow RSS feed for a specific question:
For this, I am using the TouchXML library to have a problem in the following code:
CXMLDocument * parser = [[CXML document alloc] initWithData: sourceData option: 0 error: zero] ; NSArray * allEntries = [Parsons nodesforxpath: @ "// entry" error: zero]; NSLog (@ "Entries entered:% d", [All entries count]); // Returns 0
The count of all entries in the NSLog details feed should be returned. In this case it should be '3', the problem is that it gives 0.
I found that this code works:
CXMLDocument * preParser = [[CXML document alloc] initWithData: sourceData option: 0 error: zero]; NSString * sourceStringUTF8 = [Preprors XMLString]; [Preemptor release]; CXML Document * Pars = [[CxML Document Alok] InitVheDatata: [sourceStringUTF8 Data Wrapping Encoding: NSUTF8 String Encoding] Option: 0 Error: Zero]; NSArray * allEntries = [Parsons nodesforxpath: @ "// entry" error: zero]; NSLog (@ "Entries entered:% d", [All entries count]); // Returns 3, which is ok
but it seems to be used (it is probably) and introduces some other sporadic bugs.
As far as I know the Expath expression is correct I have also checked it using the page.
Can anyone help me with this problem, or can I tell me in the right direction.
Thank you.
I had a very similar problem. This is something with the XML namespace, which is not very well supported by TouchXML (a known issue).
I believe that in your hack, the namespace was not passed in the other parser, why it works.
An easy way is to change only
& lt; Html xmlns = "http://www.w3.org/1999/xhtml" lang = "n" xml: lang = "en" & gt;
only
& lt; Html & gt;
And xPath now works.
Comments
Post a Comment