Re: XML to AppleScript Record
Re: XML to AppleScript Record
- Subject: Re: XML to AppleScript Record
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 3 Mar 2008 15:13:14 -0500
On Mon, Mar 3, 2008 at 2:24 PM, Stockly, Ed <email@hidden> wrote:
> Has anyone tried converting XML data to an appleScript record, using
> the xml tags as record labels.
A general solution for such a thing would take us right back to the
"records vs associative arrays" argument. It doesn't make sense to do
things that way unless you know ahead of time what the XML will look
like. (The LNS XML Tools osax does build records out of XML, but the
records are DOM structures with set keys; all the dynamic data winds
up in values.)
> <root>
> <xmlDataFormat Version="1.1">
> <dataTagFoo>
> <dataTagBar>
> "Data"
> </dataTagBar>
> <dataTagMore>
> "More Data Data"
> </dataTagMore>
> </dataTagFoo>
> </root>
>
... which is invalid XML since the xmlDataFormat element is unclosed,
but let's just assume that's a /> at the end and move on...
> Should translate as:
>
> {root:{{xmlDataFormat:{version:"1.1:"}}, {dataTagFoo:{dataTagBar:"Data"}},
> {dataTagMore:"More Data Data"}}}
Two questions about the above:
1. Is that AS syntax, where the quotes are just string delimiters?
Meaning you expect the quotation marks within the XML to be dropped?
(Quotation marks around attribute values are required and not part of
the value; but quotation marks within text inside elements are
literal.)
2. You don't need to distinguish between attributes and values?
Inferring the mapping rules from your example, the same record would
be generated by this XML:
<root>
<xmlDataFormat><version>1.1</version></xmlDataFormat>
<dataTagFoo dataTagBar="Data" dataTagMore="More Data Data"/>
</root>
> I couldn't see how to do this with any of the XML osax or system events.
> Am I missing something?
I suspect not.
--
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