• 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 10:30:34 +0900

I'm basically trying to convert the "used range" of an Excel sheet into a specific XML dialect but I'm not seeing any dictionary item that could help.

That's a difficult question to answer without knowing what format XML you want. System Events has an XML Suite, but I'm not sure it will give you an XML string for anything but a complete document. It's also incredibly slow for anything not very simple.

And the other option is AppleScriptObjC. Here's something very simple:

Shane, that's exactly what I was looking for.

Of course, what I'm intending to do is slightly more complex, but now I know that I just need to fiddle with the XMLNode class to find what I need. Excellent :)

Jean-Christophe 


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

 _______________________________________________
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: Lists to XML ?
  • 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