• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iPhone: NSXMLParser problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPhone: NSXMLParser problems


  • Subject: Re: iPhone: NSXMLParser problems
  • From: Jeremy Pereira <email@hidden>
  • Date: Tue, 5 Jan 2010 11:38:44 +0000

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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden


______________________________________________________________________
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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: iPhone: NSXMLParser problems
      • From: "Eric E. Dolecki" <email@hidden>
References: 
 >iPhone: NSXMLParser problems (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: Getting warning when saving merged MOC
  • Next by Date: Re: iPhone: NSXMLParser problems
  • Previous by thread: iPhone: NSXMLParser problems
  • Next by thread: Re: iPhone: NSXMLParser problems
  • Index(es):
    • Date
    • Thread