Re: Accessing attributes of XML (Christian Graus)
Re: Accessing attributes of XML (Christian Graus)
- Subject: Re: Accessing attributes of XML (Christian Graus)
- From: "Christian Graus" <email@hidden>
- Date: Tue, 6 May 2008 10:59:32 +1000
On Tue, May 6, 2008 at 10:55 AM, Richard Wolf <email@hidden> wrote:
>
> On May 5, 2008, at 6:49 PM, email@hidden 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:
>
*grin* there are moderators.
>
> 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. :)
>
Thanks - to be honest, I wouldn't mind learning XQuery. But, in the first
instance, it seemed to me that XPath would do the job. Visual Studio has
supported XQuery for some time, but, like I said, I bought the book and
never found the time. I will probably play with the syntax you've provided,
I do think being able to mix both is cool, although I'd have preferred to
see an interface closer to the DOM, for people coming from DOM methods,
truth is that the core issue was me learning to use the IDE, once I knew how
to use the debug console, I found my code had been working, just my
assumptions about the IDE and the info it would provide, turned out to be
wrong.
Thanks for your help, I expect to have a lot of questions here ( and
hopefully some answers, with time ), so I really appreciate all who jumped
in to assist me with this.
Christian
>
> And now I go back to lurking. :)
>
> _______________________________________________
>
> 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
>
_______________________________________________
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