• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Lists to XML ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Lists to XML ?
      • From: Shane Stanley <email@hidden>
References: 
 >Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: Lists to XML ? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Detect when I start to work...
  • Next by Date: Re: Lists to XML ?
  • Previous by thread: Re: Lists to XML ?
  • Next by thread: Re: Lists to XML ?
  • Index(es):
    • Date
    • Thread