global target_file
global theXML
global thetitle
tell application "System Events"
activate
set thefile to (choose file without invisibles)
set x to the POSIX path of thefile
set f to the XML file x
set root to XML element 1 of f
set NextRoot to XML element 1 of XML element 1 of f
get properties of root
get properties of NextRoot
get value of every XML element of NextRoot
set theHost to the value of XML element 2 of NextRoot
set theSynopsis to the value of XML element 6 of NextRoot
set theMusic to the value of XML element 3 of NextRoot
set thetitle to the value of XML element 1 of NextRoot
end tell
set theXML to ("<?xml version=\"1.0\"?>
<FinalCutServer>
<entity entityType=\"asset\" entityId=\"/asset/" & thetitle & "\">
<metadata>
<mdValue fieldName=\"Host\" dataType=\"string\">" & theHost & "</mdValue>
<mdValue fieldName=\"Musical Guest\" dataType=\"string\">" & theMusic & "</mdValue>
<mdValue fieldName=\"Synopsis\" dataType=\"string\">" & theSynopsis & "</mdValue>
</metadata>
</entity>
</FinalCutServer>")
set target_file to ((path to desktop) & thetitle & ".xml")
try
set theTarget to (target_file as alias)
if theTarget exists then
tell application "Finder"
delete theTarget
end tell
end if
end try
write_to_file(theXML)
end run
on write_to_file(theXML)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
set eof of open_target_file to 0
write theXML to the open_target_file starting at eof
close access the open_target_file
on error
try
close access file target_file
end try
end try
end write_to_file
This script works well providing the XML that is getting ingested is simple (one clip).