| Issue 40: | Atom feeds problem with Xpath | |
| 4 people starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem? 1. Create an CXMLDocument for an atom feed eg. http://theraneman.blogspot.com/feeds/posts/default 2. CXMLDocument *rssParser= NULL; rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease]; titlearray = [rssParser nodesForXPath:@"//title" error:nil]; What is the expected output? What do you see instead? OF course there are title elements but the array count is 0. This works for RSS feeds. What version of the product are you using? On what operating system? Using latest version on Mac 10.5.5 Please provide any additional information below. Seems this is the problem of ATOM feeds with XPATH. Any help is appreciated.
Jan 20, 2009
#1
thetazz...@gmail.com
Jan 20, 2009
I'll look at bug as time/resources allow. Don't forget that you have the access to all the source and the community would welcome any fixes. Feel free to support TouchCode via http://toxicsoftware.com/touchcodedonate/ if that floats your boat.
Jan 20, 2009
Hi there, After searching al lot in the cloud for this issue I realized that this was a problem faced by several RSS client developers. For my iphone app I am now using NSXMLParser which is just a light weight parser with no xpath support. Thanks Abhang
Feb 28, 2009
Closing.
Status:
Invalid
Jun 6, 2009
I think this is related to issue #37 , so I'm posting this information in that thread as well. This issue is actually related to how libxml2 works. With atom feeds, the default namespace has to be defined and used in your XPath queries, or you have to construct your XPath queries so that they specifically handle the default namespace. I figured this out from this page: http://philwilson.org/blog/2007/11/parsing-atom-with-libxml2 Without defining any namespaces, you need to use this kind of XPath query: //*[local-name()='feed'] instead of this: //feed Here's how you can define namespaces with TouchXML when querying for XPath. This example is against an atom feed generated by ADO.NET Data Services: DataServiceParser *dataServiceParser = [[DataServiceParser alloc] initWithContentsOfURL:urlUpdateDataService options:0 error:&error]; if(dataServiceParser) { NSArray *entries; NSDictionary *dictNameSpaceMappings = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"http://www.w3.org/2005/Atom", @"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", nil] forKeys:[NSArray arrayWithObjects:@"atom", @"m", nil]]; entries = [dataServiceParser nodesForXPath:@"/atom:feed/atom:entry/atom:content/m:properties" namespaceMappings:dictNameSpaceMappings error:&error]; So, I wouldn't consider this a bug or issue with TouchXML, it's just a technique you must use for atom feeds with any XML library based on libxml2. |