FCP XML listing .movs in a seq

I am trying to get an xml from FCP to list the .mov files in an edit sequence. Its listed in the xml element called “pathurl”

here is my script so far(yes i know I am crap at this but I am trying to improve)

set xx to {}
set destination_folder to (choose folder with prompt "select destination folder")
set Master_xml_folder to (choose folder with prompt "select the folder that contains the xmls")

tell application "Finder"
	set xml_file_list to files of folder Master_xml_folder
end tell

repeat with current_xml_file in (items 1 thru (count of xml_file_list) of xml_file_list)
		set the_URL to (current_xml_file as alias)
		set the_doc to XMLOpen the_URL
		set the_root to XMLRoot the_doc
		set the_child to XMLChild the_root index 1
		set media_branch to XMLFind the_child name "media"
		set video to XMLFind media_branch name "video"
		set numboftracks to XMLCount video
		--so that I skip over the branch called "format"
		set numberofvideotracks to numboftracks - 1
		set trackcounter to 2
		--working with 1 track at a time
		repeat with i from 1 to numberofvideotracks
			set track to XMLChild video index trackcounter
			set clipitem to XMLFind video name "track"
			set numbofclips to XMLCount clipitem
			--working with 1 clip at a time in the current track
			set numbofclips_count to 1
			repeat with ii from 1 to numbofclips
					set next_clipitem to XMLChild track index numbofclips_count
					set file_ to (XMLFind next_clipitem name "file")
					set pathurl to (XMLFind file_ name "pathurl")
					set pathurl_to_move to XMLGetText pathurl
					--makeing the list of files to copy	
					set end of mylist to pathurl_to_move
					set numbofclips_count to numbofclips_count + 1
				on error
					display dialog "error"
				end try
			end repeat
			--move to the next track
			set trackcounter to trackcounter + 1
		end repeat
	end try
end repeat

--b109c2 2,1
--a127c3 2,2
--a125c7 3,2

I can get the first two .movs in the xml into the list but not the 3rd one. the 3rd one is on track 2.
I think it may be because some of the branches of the clipitem part of the xml dont have the pathurl information. but I dont know anymore.

Can anyone see where I am going wrong?


Here is a shortened version of the xml

<?xml version="1.0" encoding="UTF-8"?> 4687C78B-BE4D-4C6F-9B47-83902BC2A823 add 4/11test2 762 FALSE 25 FALSE 25 01:00:00:00 90000 source NDF -1 -1 FALSE

Hi, I copied your example xml into a TextEdit document and ran this code. It shows an easy way using applescript’s text item delimiters to extract the pathurl…

-- get the text of the text edit's front document
tell application "TextEdit"
	set t to text of document 1
end tell

set pathURLs to {}

-- use text item delimiters to find the pathurls
set {tids, text item delimiters} to {text item delimiters, "<pathurl>"}
set ti to text items of t
set text item delimiters to "</pathurl>"
repeat with i from 2 to count of ti
	set theItems to text items of (item i of ti)
	set end of pathURLs to item 1 of theItems
end repeat
set text item delimiters to tids

return pathURLs

much simpler.

thanks soooooo much.