Re: Lists to XML ?
Re: Lists to XML ?
- Subject: Re: Lists to XML ?
- From: Steve Mills <email@hidden>
- Date: Fri, 24 Mar 2017 07:59:03 -0500
On Mar 24, 2017, at 07:36:23, Jean-Christophe Helary <email@hidden> wrote:
>
> elementWithName is a class method, that's the reason why it must apply to the NSXMLNode class
>
> and by doing that I create an instance of the class that is listElement to which I should be able to apply instance methods...
>
> so, when I use addChild on listElement, it works because addChild is an instance method.
>
> Now, what if I want to add an attribute and it's string value to an element?
>
> addAttribute is an instance method so it should work on newNode but that does not seem to be the case...
Use NSXMLNode's + (id)attributeWithName:(NSString*)name stringValue:(NSString*)stringValue; to create an attribute object, then you can use addAttribute to add that object to the element. There's also -setAttributesWithDictionary: which is really handy if you have everything you need right up front:
[elem setAttributesWithDictionary:@{@"name":theName, @"id":theID}];
--
Steve Mills
Drummer, Mac geek
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden