My favorites | Sign in
Project Home
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 37: Tags labeled as <xxxx:yyyyy>
3 people starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  Feb 2009


 
Reported by alvaro.p...@gmail.com, Nov 11, 2008
Well, Im trying to parse Youtube Atom output as describe here:

https://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Understanding_Video_Entries

I have managed to get the video titles with:
NSArray *keys = [NSArray arrayWithObjects:@"yt", @"m", nil];
	NSArray *objects = [NSArray
arrayWithObjects:@"http://www.w3.org/2005/Atom",
@"http://search.yahoo.com/mrss/", nil];
	NSDictionary *dict= [NSDictionary dictionaryWithObjects:objects forKeys:keys];
    resultNodes = [rssParser nodesForXPath:@"//yt:entry"
namespaceMappings:dict error:NULL];
for (CXMLElement *resultElement in resultNodes) {
    NSArray *titleNodes = [resultElement nodesForXPath:@"./yt:title" 
namespaceMappings:dict error:NULL];
}

But I cant get the tags labeled as media:group, media:description and so
on. For that Im trying:

NSArray *thumbsNodes = [resultElement nodesForXPath:@"./m:media/group" 
namespaceMappings:dict error:&theError];

I get an error if trying: @"./m:media:group" 
and zero elements if trying the above solution. Is there a bug dealing with
this class of tags or it is just my stupidity???

Regards,
Picapau



Feb 28, 2009
Project Member #1 jwight
Old bug.
Status: Invalid.
Feb 28, 2009
Project Member #2 jwight
(No comment was entered for this change.)
Status: Invalid
Mar 25, 2009
#3 RanyAch...@gmail.com
i have the same problem tying to parse an atom feed .. any progress ??
Jun 6, 2009
#4 mitch.h...@gmail.com
I think this is related to  issue #40 , 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.



Powered by Google Project Hosting