XML help please

Please can anyone help!

I have a simple XML file that I would like to extract the values from using applescript. But I can’t figure out how to get the results I need.

What I need is a list of records with the name, Coverage and CoveragePerc of each Ink.

I can get the names of the inks using the script below but I can’t figure out how to get the other 2 properties of each ink

My script looks like this at the moment:


set theFile to (choose file)
set ColourInfo to getXMLJobInfo(theFile)


on getXMLJobInfo(theFile as string)
	tell application "System Events"
		tell XML file theFile -- alias as string
			tell XML element "InkCoverage"
				tell XML element "Inks"
					set CompleteColourInfo to {} as list
					set NoOfColours to count of every XML element
					repeat with ii from 1 to NoOfColours
						set ThisColourInfo to {InkName:"", InkCoverage_Percent:0, InkCoverage_mm:0}
						tell XML attribute of XML element ii
							set InkName of ThisColourInfo to (value)
							
							-- somehow get Coverage Value of this ink
							-- somehow get CoveragePerc Value of this ink
							
						end tell
						set the end of CompleteColourInfo to ThisColourInfo
					end repeat
				end tell
			end tell
		end tell
	end tell
	return CompleteColourInfo
end getXMLJobInfo

and the XML file’s text (saved to my desktop) is

“<?xml version="1.0" encoding="UTF-8"?>



























Hope this is clear

Thanks

Here you go:


set theFile to (choose file)
set ColourInfo to getXMLJobInfo(theFile)

on getXMLJobInfo(theFile as text)
	set CompleteColourInfo to {}
	tell application "System Events"
		tell XML element "Inks" of XML element "InkCoverage" of XML file theFile
			set NoOfColours to count of every XML element
			repeat with ii from 1 to NoOfColours
				tell XML element ii
					set InkName to value of XML attribute "Name"
					set coverageValue to value of XML attribute "Value" of XML element "Coverage"
					set coveragePercValue to value of XML attribute "Value" of XML element "CoveragePerc"
				end tell
				set the end of CompleteColourInfo to {InkName:InkName, InkCoverage_Percent:coveragePercValue, InkCoverage_mm:coverageValue}
			end repeat
		end tell
	end tell
	return CompleteColourInfo
end getXMLJobInfo

Perfect!

Thanks Stefan.

I was getting a bit frustrated, I should have been able the figure it out but couldn’t wrap my head around it.

Thank you