• 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: Fri, 24 Mar 2017 21:36:23 +0900

Testing my understanding of this ASObjC thing... Totally scary but exciting...

On Mar 24, 2017, at 8:14, Shane Stanley <email@hidden> wrote:

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

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...

I'm kind of lost here.

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: Steve Mills <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: Thoughts on Workflow acquisition?
  • Previous by thread: Re: Lists to XML ?
  • Next by thread: Re: Lists to XML ?
  • Index(es):
    • Date
    • Thread