Re: XML to AppleScript Record
Re: XML to AppleScript Record
- Subject: Re: XML to AppleScript Record
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 5 Mar 2008 09:00:05 -0500
The Perl XML::Simple module works similarly, fyi.
On 3/5/08, has <email@hidden> wrote:
> On 5 Mar 2008, at 10:41, Skeeve wrote:
>
> > <root>
> > <xmlDataFormat Version="1.1"/>
> > <dataTagFoo>
> > <dataTagBar>
> > "Data"
> > </dataTagBar>
> > <dataTagMore>
> > "More Data Data"
> > </dataTagMore>
> > </dataTagFoo>
> > </root>
> > [...]
> > If you want to install some Perl Modules, you could achieve this
> > with XML::Twig, converting the XML to AppleScript source code.
>
> Code generation is almost always the wrong solution to a given
> problem. However, I'll second using another language's libraries to do
> all the heavy lifting. For example, using Python's ElementTree module
> and the recipe from:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410469
>
> it is trivially easy to convert an XML file or string such as the
> above to a Python dictionary:
>
> {
> 'dataTagFoo': {
> 'dataTagBar': '\n "Data"\n ',
> 'dataTagMore': '\n "More Data Data"\n '
> },
> 'xmlDataFormat': {'Version': '1.1'}
> }
>
>
> From there, it's a small step to wrap this code as a scriptable FBA
> [1] that converts XML files/strings to AppleScript records:
>
> tell app "XMLToRecord" to convert xmlFile
>
> --> {|dataTagFoo|:{|dataTagBar|:"
> \"Data\"
> ", |dataTagMore|:"
> \"More Data Data\"
> "}, |xmlDataFormat|:{|Version|:"1.1"}}
>
> has
>
> [1] See the aemreceive module included in the Python appscript
> package; documentation and tutorials can be found in the .tar.gz
> distro. (Or you can pay us to write it for you, if you wish.)
> --
> http://appscript.sourceforge.net
>
> _______________________________________________
> 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
>
--
Mark J. Reed <email@hidden>
_______________________________________________
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