Christian,

It's just like I posted to Mr. Gecko. XQuery is your friend. XPath returns nodes, XQuery allows you to return values.

An XQuery to return the text inside your DiaIndex/Items is simple ... it would look like this:

   let $result := ./DiaIndex/Item return $result

Notice that XQuery uses XPath ... XQuery 1.0 is inseparable from XPath 2.0.

In Cocoa, you can ask an NXXMLNode (including your root node) to execute an XQuery and return the result as an NSArray of Cocoa things (what's returned depends on what data types XQuery sees in your XML ... it's usually NSStrings). It is simple to change your code to execute the XQuery.

NSXMLDocument *doc = [[NSXMLDocument alloc]
   initWithContentsOfURL:xmlURL options:0 error:&error];

NSXMLNode *node = [doc rootElement];

NSArray *array = [node
objectsForXQuery:@"let $result := ./DiaIndex/Item return $result" error:&error];

Guess what "array" has? A set of NSStrings that are the contents of your /DiaIndex/Items. :)

It's just that simple.  :)

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to