XML work with applescript

I am trying to get some info out of an xml.
Below is a line from an XML.

  <Event Num="1" Type="Delete" Subtype="Clip" Length="25">

I want to assign the value after Type= to a variable in applescript.

I have used http://www.latenightsw.com/freeware/XMLTools2/ on other XMLs with success.
but I cant figure out how I might get to the value after Type=
Its probably staring me in the face but I just cant see it

here is a portion of the XML

<?xml version='1.0' encoding='UTF-8'?> 02:00:00:00 0000+00 0 02:00:00:24 0001+08 24 02:00:01:00 fscltest1 01:00:00:00 01:00:00:24 01:00:01:00 50-5 060a2b340101010101010f00-13-00-00-00-{4ec48c13-e4e0-007e-060e2b347f7f2a80} 803643 08:55:45:18 B072C009_111116_R2E6-0083643 803667 08:55:46:17 B072C009_111116_R2E6-0083667 08:55:46:18 5 P RW B072C009_111116_R2E6 BLOOD_16D11M11 B072R2E6

etc etc

Does anyone have a suggestion of a script?

below are the routines I have used in the past


on list_position(this_item, this_list)
	repeat with i from 1 to the count of this_list
		if item i of this_list is this_item then return i
	end repeat
	return 0
end list_position

on getAnElement(theXML, theElementName)
	-- find and return a particular element (this presumes there is only one instance of the element)
	
	repeat with anElement in XML contents of theXML
		if class of anElement is XML element and ¬
			XML tag of anElement is theElementName then
			return contents of anElement
		end if
	end repeat
	
	return missing value
end getAnElement

on getElements(theXML, theElementName)
	-- find and return all instatnces of a particular element
	
	local theResult
	
	set theResult to {}
	repeat with anElement in XML contents of theXML
		if class of anElement is XML element and ¬
			XML tag of anElement is theElementName then
			set end of theResult to contents of anElement
		end if
	end repeat
	
	return theResult as list
end getElements



on getElementFromPath(theXML, theElementPath)
	if theElementPath is {} then
		return theXML
	else
		local foundElement
		
		set foundElement to getAnElement(theXML, item 1 of theElementPath)
		if foundElement is not missing value and ¬
			class of foundElement is XML element then
			return getElementFromPath(foundElement, rest of theElementPath)
		else
			return missing value
		end if
	end if
end getElementFromPath

on getNamedElement(theXML, theElementName, theName)
	-- find and return the first element with a particular name attribute
	
	if class of theXML is XML element or class of theXML is XML document then
		repeat with anElement in XML contents of theXML
			try
				if class of anElement is XML element and ¬
					XML tag of anElement is theElementName and ¬
					|name| of XML attributes of anElement is theName then
					return contents of anElement
				end if
			on error number -1728
				-- ignore this error
			end try
		end repeat
	else if class of theXML is list then
		repeat with anElement in theXML
			try
				if class of anElement is XML element and ¬
					XML tag of anElement is theElementName and ¬
					|name| of XML attributes of anElement is theName then
					return contents of anElement
				end if
			on error number -1728
				-- ignore this error
			end try
		end repeat
	end if
	
	return missing value
end getNamedElement

Hi,

you can parse XML files without any third party additions


set xmlPath to "MacHD:path:to:XMLFile.xml"
tell application "System Events"
	set xmlFile to XML file xmlPath
	tell contents of xmlFile
		set eventXMLElement to XML element 1 of XML element "Events" of XML element "ChangeList" of XML element "FilmScribeFile"
		set typeAttribute to value of XML attribute "Type" of eventXMLElement
	end tell
end tell

Thanks,
I found the problem.

I needed to specify |Type| not name in the routine

on list_position(this_item, this_list)
	repeat with i from 1 to the count of this_list
		if item i of this_list is this_item then return i
	end repeat
	return 0
end list_position

on getAnElement(theXML, theElementName)
	-- find and return a particular element (this presumes there is only one instance of the element)
	
	repeat with anElement in XML contents of theXML
		if class of anElement is XML element and ¬
			XML tag of anElement is theElementName then
			return contents of anElement
		end if
	end repeat
	
	return missing value
end getAnElement

on getElements(theXML, theElementName)
	-- find and return all instatnces of a particular element
	
	local theResult
	
	set theResult to {}
	repeat with anElement in XML contents of theXML
		if class of anElement is XML element and ¬
			XML tag of anElement is theElementName then
			set end of theResult to contents of anElement
		end if
	end repeat
	
	return theResult as list
end getElements



on getElementFromPath(theXML, theElementPath)
	if theElementPath is {} then
		return theXML
	else
		local foundElement
		
		set foundElement to getAnElement(theXML, item 1 of theElementPath)
		if foundElement is not missing value and ¬
			class of foundElement is XML element then
			return getElementFromPath(foundElement, rest of theElementPath)
		else
			return missing value
		end if
	end if
end getElementFromPath

on getNamedElement(theXML, theElementName, theName)
	-- find and return the first element with a particular name attribute
	
	if class of theXML is XML element or class of theXML is XML document then
		repeat with anElement in XML contents of theXML
			try
				if class of anElement is XML element and ¬
					XML tag of anElement is theElementName and ¬
					|Type| of XML attributes of anElement is theName then
					return contents of anElement
				end if
			on error number -1728
				-- ignore this error
			end try
		end repeat
	else if class of theXML is list then
		repeat with anElement in theXML
			try
				if class of anElement is XML element and ¬
					XML tag of anElement is theElementName and ¬
					|Type| of XML attributes of anElement is theName then
					return contents of anElement
				end if
			on error number -1728
				-- ignore this error
			end try
		end repeat
	end if
	
	return missing value
end getNamedElement


set changelistxml to {}

set changelistxml to (choose file with prompt "select MASTER ss template") as alias
set eventsxml to getAnElement((getAnElement(parse XML changelistxml, "ChangeList")), "Events")
set xmlevent to getAnElement(eventsxml, "Event")

if XML contents of (getNamedElement(eventsxml, "Event", "Delete")) is not equal to missing value then
	display dialog "found attribute"
end if