On May 5, 2008, at 6:49 PM, [EMAIL PROTECTED] wrote:

I had to pick up the XPath stuff recently for a project I was working
on, and I've got to say that once you get yourself thinking in that
way, it's really very nice for inspecting XML files, giving you great,
readable control for grabbing segments out of the document and then
inspecting or manipulating them.

Yes, XPath is very nice and very powerful, once you get the hang of it.

I confess to having an XQuery book that i've never read, because XPath has always worked, and I've never worked on a project where anyone else saw a
need for XQuery.

Christian,

I hate to beat a dead horse (and I'm totally going to shut up after this post ... all glory to the moderators!), but what you're after can be done using a single Cocoa method and XQuery:

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

In return, you get an array of NSStrings which represent the element text contained in the DiaIndex Items within the root of your document.

If you need to access attributes (rather than element text), you can do that too, with a slight XPath amend. :)

I admit that learning XQuery/XPath is going to take a little bit of time ... but if I can learn Visual Studio and .NET for a project (and I have) you can totally learn XQuery. :) XQuery support in NSXMLNode is one of the unsung coolnesses in Cocoa, IMHO. :)

And now I go back to lurking.  :)

_______________________________________________

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