Re: Lists to XML ?
Re: Lists to XML ?
- Subject: Re: Lists to XML ?
- From: Jean-Christophe Helary <email@hidden>
- Date: Sat, 25 Mar 2017 07:59:20 +0900
On Mar 24, 2017, at 8:14, Shane Stanley < email@hidden> wrote:
And the other option is AppleScriptObjC. Here's something very simple:
use AppleScript version "2.4" -- Yosemite (10.10) or later use framework "Foundation" use scripting additions
set theList to {"a", "b", 1, 2, 3.3} set listElement to current application's NSXMLNode's elementWithName:"array" repeat with anItem in theList set newNode to (current application's NSXMLNode's elementWithName:"entry" stringValue:anItem) (listElement's addChild:newNode) end repeat return listElement's XMLString() as text
Shane,
I don't understand the syntax of the line:
(listElement's addChild:newNode)
I see that it looks like the previous line's
(current application's NSXMLNode's elementWithName:"entry" stringValue:anItem)
but it stands on it's own line without any AS command, *and* it's between parens.
Is there a place in your book where that is explained ?
Also, the longer line is creating an instance of a class, right ? So that's the reason why we need to have "current application", is that correct ?
Jean-Christophe |
_______________________________________________
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