Re: XML attributes
Re: XML attributes
- Subject: Re: XML attributes
- From: Shane Stanley <email@hidden>
- Date: Sun, 25 Nov 2018 12:16:06 +1100
On 24 Nov 2018, at 11:07 pm, Shane Stanley <email@hidden> wrote:
>
> Would something like this work for you:
Let me clean up some of the nomenclature there:
on addChildOrAttributesTo:parentElement withDictionary:theDict
set theKeys to theDict's allKeys() as list
repeat with i from 1 to count of theKeys
set theKey to item i of theKeys
set theValue to (theDict's objectForKey:theKey)
if theKey as text = "attributes" then
(parentElement's setAttributesWithDictionary:theValue)
else if theKey as text = "value_and_attributes" then
set newDict to (theDict's objectForKey:theKey)
set newName to (newDict's objectForKey:"value")
set theAtts to (newDict's objectForKey:"attributes")
(parentElement's setAttributesWithDictionary:theAtts)
(parentElement's setObjectValue:newName)
else
set newElement to (current application's NSXMLNode's
elementWithName:theKey)
(parentElement's addChild:newElement)
if (theValue's isKindOfClass:(current application's
NSDictionary)) as boolean then
(its addChildOrAttributesTo:newElement
withDictionary:theValue)
else
(newElement's setObjectValue:theValue)
end if
end if
end repeat
end addChildOrAttributesTo:withDictionary:
--
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