• 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: "Eric E. Dolecki" <email@hidden>
  • Date: Tue, 5 Jan 2010 08:26:11 -0500

Immediately after the [parser parse] I check it:

if( [parser parseError]){
    NSLog(@"parse error");
}

This always fires - but I think that the XML is valid. My delegate methods
aren't firing at all - so I don't think it's a namespace issue. Does the
code seem okay?

If I dump the stringReply into a UIWebView it renders it fine. I just want
to pull out current conditions and get the image (gif) to display in a
UIImageView...



On Tue, Jan 5, 2010 at 6:38 AM, Jeremy Pereira <email@hidden> wrote:

>
> 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
> ______________________________________________________________________
>



--
http://ericd.net
Interactive design and development
_______________________________________________

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>)
 >Re: iPhone: NSXMLParser problems (From: Jeremy Pereira <email@hidden>)

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