• 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: Shane Stanley <email@hidden>
  • Date: Fri, 24 Mar 2017 10:14:33 +1100

On 24 Mar 2017, at 2:31 am, Jean-Christophe Helary <email@hidden> wrote:

What would be the best way to convert AS lists into XML ?

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:

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 Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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: Jean-Christophe Helary <email@hidden>
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
    • Re: Lists to XML ?
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Lists to XML ? (From: Jean-Christophe Helary <email@hidden>)

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