Re: Accessing attributes of XML
Re: Accessing attributes of XML
- Subject: Re: Accessing attributes of XML
- From: "Christian Graus" <email@hidden>
- Date: Tue, 6 May 2008 08:36:09 +1000
On Tue, May 6, 2008 at 8:27 AM, Jens Alfke <email@hidden> wrote:
>
> On 5 May '08, at 2:30 PM, Christian Graus wrote:
>
> As for NSMXLNode, I moved to NSXMLElement to get access to
> > attributeForName, I was using NSXMLNode before that, still to no avail.
> >
>
> No, I meant to change this line:
> NSXMLElement *name = [node2 attributeForName:@"Name"];
> That should be declared as NSXMLNode*, because that's what kind of object
> attributeForName: returns. Changing the pointer's type won't affect what the
> object itself is.
>
OK - thanks. I will try that. My reading had me thinking that NSXMLElement
and NSXMLDocument are both derived from NSXMLNode, and that anyting bar the
root was an NSXMLElement, with methods returning NSXMLNode as a base class
to all nodes.
>
>
> although I suspect we're going to move to the DOM implimentation I found
> > in the docs last night.
> >
>
> AFAIK, the only DOM APIs are in WebKit, and require you to use a WebView.
> They're not meant for general XML parsing. NSXML is actually a lot more
> powerful in that it allows you to use XPath and XQuery expressions to find
> and extract values really easily.
>
Yeah, that's where I found the docs. IMHO it's a real shame that a proper
DOM implimentation is not available as standard. I am familiar with XQuery,
but I've never known anyone to use it, perhaps it's used more on Mac ? I'm
just surprised to see Microsoft adhering to standards and Apple not doing
so. I learned to DOM for the same reason I learned C++, so I had cross
platform, standard skills. I am assuming with the help you've given me,
I'll be better able to examine what is happening in my code, and work out
where I have gone wrong, because what you're saying mostly is reiterating
the docs, and most of your suggestions, I have tried. I am assuming it's
actually working, but because this is my first OC program, I am making some
gross beginners error in getting access to the result.....
>
>
> Using a standard interface would really help me, especially as there
> > doesn't seem to be any intellisense in XCode.
> >
>
> I'm not sure what Intellisense is; some Microsoft IDE thing? If you mean
> autocomplete, Xcode has that, although the default key bindings for it are
> pretty arcane. Search the docs for the commands like Next Completion and
> Completion List. And you can Command-double-click a symbol to jump to its
> definition in a header, or Option-double-click to view it in the API
> documentation.
Thanks - I will look for that. Yes, in the MS IDE, if I type an object name
and a . or -> ( because it would be C++ ), a list of possible methods to
call appears. I find that very helpful for learning new libraries, although
obviously with time, the need for them lessens as I get to know them.
Thanks again for your help, I really appreciate it.
Christian
>
>
> —Jens
_______________________________________________
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