On 5 Jan 2010, at 05:09, Eric E. Dolecki wrote: > > - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName > namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName > attributes:(NSDictionary *)attributeDict { > > NSLog(@"didStartElement"); > > //not sure how to handle namespaces in obj-c > > if( [elementName isEqualToString:@"yweather:condition"]){ > > NSString *thisOwner = [attributeDict objectForKey:@"text"]; > > NSLog(@"%@", thisOwner); > > } > > } > >
I'm fairly sure that, if you are processing namespaces, elementName will not have the prefix when it comes in. Instead, the parser will maintain a mapping between the namespace URI and the prefix. You need to test that the passed in namespaceURI matches the URI you are interested in and the elementName is the element name you are interested in. qName will contain the prefix, but if you use that to do the test, you'll have to track how the prefixes are currently mapped (there's a delegate method to help you with that), parse out the prefix and look up its namespace. The reason is that for any given element you can't guarantee that the condition element will always be prefixed by "yweather", it depends on the previous xmlns mapping, nor can you guarantee that the yweather prefix always refers to the namespace for Yahoo weather XML, nor can you even guarantee there will even be a prefix e.g. <condition xmlns="http://yahoo.weather.namespace">.... is perfectly acceptable. > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net > > This email sent to a...@jeremyp.net ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com