• 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: referencing XML Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: referencing XML Data


  • Subject: Re: referencing XML Data
  • From: "Sherm Pendley" <email@hidden>
  • Date: Tue, 16 Sep 2008 14:52:03 -0400

On Tue, Sep 16, 2008 at 7:39 AM, Amy Heavey <email@hidden>wrote:

>
> NSArray *customerArray = [custdoc nodesForXPath:@".//customer" error:nil];
>                if ([customerArray count]){
>                        NSXMLNode *customerNode;
>                        for (customerNode in customerArray) {


error: parse error before 'in'

That should be:

    for (NSXMLNode *customerNode in customerArray) {

                               NSArray *firstNameArray;
>                                firstNameArray = [customerNode
> nodesForXPath:@".//first_name" error:nil];
>                                        if ([firstNameArray count]){
>                                                NSString *firstNameString =
> [firstNameArray objectAtIndex:0] stringValue];
>

error: parse error before 'stringValue'

You're missing an opening bracket "[" above. It should be:

    NSString *firstNameString = [[firstNameArray objectAtIndex:0]
stringValue];


> printf("First name= %s\n", firstNameString);
>

%s is the format specifier for C strings, not NSString objects. As far as I
know, printf() doesn't grok the %@ format specifier for objects, so you'll
need to use NSLog() instead:

    NSLog(@"First name = %@", firstNameString);

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________

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: referencing XML Data
      • From: Nathan Kinsinger <email@hidden>
    • Re: referencing XML Data
      • From: Amy Heavey <email@hidden>
References: 
 >referencing XML Data (From: Amy Heavey <email@hidden>)
 >Re: referencing XML Data (From: Nathan Kinsinger <email@hidden>)
 >Re: referencing XML Data (From: Amy Heavey <email@hidden>)

  • Prev by Date: Re: Bug with -changeAttributes: in NSFontManager/Font Panel?
  • Next by Date: Re: Abusing targetForAction: with non-action selectors
  • Previous by thread: Re: referencing XML Data
  • Next by thread: Re: referencing XML Data
  • Index(es):
    • Date
    • Thread