Trying to convert a AppleScript record to NSXMLDocument and then have it's NSstring content

I’m trying to convert a AppleScript record to NSXMLDocument and then read it out as a string to add it the XMP metadata of a InDesign file.

I start with the following code

set allCheckboxes to {"Jachtdagen", "Dagen"}
set rootElement to current application's NSXMLNode's elementWithName:("checkboxesToCross")
repeat with v from 1 to count of allCheckboxes
	set _value to item v of allCheckboxes
	set newElement to (current application's NSXMLNode's elementWithName:"checkboxes" stringValue:_value)
	
	(rootElement's addChild:newElement)
	
end repeat

set _XmlDoc to current application's NSXMLDocument's alloc()'s initWithRootElement:rootElement

And now I want to have the _XmlDoc as text, but I can’t figure it out…
Any help greatly appreciated.

It seems that easy… :hot_face: after searching and searching…

set theXMLString to _XmlDoc's XMLStringWithOptions:(current application's NSXMLNodePrettyPrint)

1 Like