• 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
efficiency of Xquery vs NSXMLElement attributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

efficiency of Xquery vs NSXMLElement attributes


  • Subject: efficiency of Xquery vs NSXMLElement attributes
  • From: Kieren Eaton <email@hidden>
  • Date: Thu, 11 Dec 2008 15:00:19 +0900

Hi All

I know there are always several ways to do things and have come across something which puzzles me as to
the efficiency of these 2 ways of getting the same data from an NSXMLNode object.


for this exercise assume theNode is an NSXMLNode object which has been initialized and contains data and an attribute called class with something in it.

Scenario 1

NSXMLElement *nodeAsElement = (NSXMLElement *)theNode;
NSString *attribContent = [[nodeAsElement attributeForName:@"class"] stringValue];
NSLog(@"class contains %@",attribContent);


Scenario 2

NSString *attribContent = [[theNode objectsForXQuery:@"data(@class)" error:nil] objectAtIndex:0];
NSLog(@"class contains %@",attribContent);


these will and do produce the same data but for my own personal knowledge I would like to know which is more efficient.
I use both in my code but am leaning more towards the xquery style for readability and maintainability of larger more nested structures.


Comments appreciated

Kieren
_______________________________________________

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: efficiency of Xquery vs NSXMLElement attributes
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
  • Next by Date: Core Data warning: to-many relation does not have an inverse
  • Previous by thread: [MEET] BYU CocoaHeads meeting Thu 12/11
  • Next by thread: Re: efficiency of Xquery vs NSXMLElement attributes
  • Index(es):
    • Date
    • Thread