Parsing XML with System Events

Hello,

I have used System Events in the past to parse XML files, but for some reason, I am having a hard time with the XML files output by Final Cut Server.

Here is the XML that I am trying to read in:

<?xml version="1.0"?> 165869421 /Anchors Laura_001.mov 2008-06-01 23:23:44+0 00:00:11;11 admin 116.621 2007-04-26 10:43:35+0 video_clip NABStuff Ready for Review 1280x1080 true 29.97 pa_asset_media raw16bit_be 58 video/quicktime true 02:29:02;05 dvcpro_hd 2008-10-01 04:05:28+0 Laura_001 2008-10-01 04:05:28+0 video

So, I am looking to pull out the Title Info, Asset ID, Status, and Creation Date. But I am getting caught with the levels of the XML.

This is not working.



tell application "System Events"
	set XMLfile to (choose file) as Unicode text
	set theXML to contents of XML file XMLfile
	set thetitle to value of XML element "Title" of XML element "Metadata" of XML element "entity" of XML element "getMdReply" of XML element "FinalCutServer" of theXML
end tell




Cheers.

Try something like this:

tell application "System Events"
	choose file without invisibles
	set xmlFile to POSIX path of result
	
	set output to {title:"", assetID:"", status:"", creationDate:""}
	
	tell XML element "getMdReply" of XML element "FinalCutServer" of XML file xmlFile
		tell XML element "metadata" of XML element "entity"
			repeat with thisElement in XML elements
				tell thisElement
					if value of XML attribute "fieldName" is "Title" then
						set title of output to its value
					else if value of XML attribute "fieldName" is "Asset ID" then
						set assetID of output to its value
					else if value of XML attribute "fieldName" is "Status" then
						set status of output to its value
					else if value of XML attribute "fieldName" is "Creation Date" then
						set creationDate of output to its value
					end if
				end tell
			end repeat
		end tell
	end tell
end tell

return output -- Check the result in Script Editor
--> {title:"Laura_001", assetID:"58", status:"Ready for Review", creationDate:"2008-06-01 23:23:44+0"}

Brilliant.

I will try it.

Cheers