Many feeds may also contain extension XML elements. If additional namespaces are used in a feed, use the extensionXMLElementsUsingNamespace: method to return an array of NSXMLElement objects. Pass the namespace URL, not the prefix, to the extensionXMLElementsUsingNamespace: method. If your feed had an entry like that in Listing 1-3, extensionXMLElementsUsingNamespace: returns an array of four NSXMLElement objects.
Listing 4-5 shows how to find a specific element in a particular namespace in an entry. In this example, the namespace is the iTunes Podcast.
Listing 4-5 Retrieving extension XML from an entry
// Find each element using the iTunes Podcast namespace |
for( NSXMLElement *elem in [entry extensionXMLElementsUsingNamespace: @"http://www.itunes.com/dtds/podcast-1.0.dtd"] ) { |
// Check if the element is called "keywords" |
if (NSOrderedSame == [[elem localName] isEqualToString:@"keywords"]) { |
// If it is, print the data from the element to the log |
NSLog(@"keywords:%@", [elem stringValue]); |
} |
} |
Last updated: 2007-05-11