Parse text from xml file.

I’m working on about 3 hours of sleep over the last few days, so please forgive me - I am certain this is easy.

I have the following xml file:

[code]

Success
9101805213907328977972
1.75
182.29
0
20090514110135
20090514
i0657
Some Description
3
1

Success 9101805213907328977972 1.75 182.29 0 20090514110151 20090514 i0648 Some Description 3 1 Success 9101805213907328977972 1.75 182.29 0 20090514110208 20090514 i0646 Some Description 3 1 Success 9101805213907328977972 1.75 182.29 0 20090514110245 20090514 i0641 Some Description 3 1 Success 9101805213907328977972 1.75 182.29 0 20090514110303 20090514 i0614 Some Description 3 1 "[/code] For each I need to obtain the and the . Can someone please show me how to parse that text out - into useable variables. Thanks.

There are several XML tools available, but if your XML is saved as a text document called XMLtemp.text on your desktop, for example, this will extract two lists – the first the Refs, and the second the Pics:

set tRefs to {}
set tPics to {}
set tXML to read alias ((path to desktop folder as text) & "XMLtemp.txt")
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "<ReferenceID>" as Unicode text
set tParts to text items 2 thru -1 of tXML
repeat with onePart in tParts
	set end of tRefs to first word of contents of onePart
end repeat
set AppleScript's text item delimiters to "<PIC>"
set tParts to text items 2 thru -1 of tXML
set AppleScript's text item delimiters to tid
repeat with onePart in tParts
	set end of tPics to first word of contents of onePart
end repeat
set myParse to {tRefs, tPics}
-->{{"i0657", "i0648", "i0646", "i0641", "i0614"}, {"9101805213907328977972", "9101805213907328977972", "9101805213907328977972", "9101805213907328977972"}}

System Events has built in XML file reading capability that is a little easier to implement. I put your XML text into a file on my desktop called test.xml

set XMLfile to (path to desktop as text) & "test.xml"
set theValuesList to {}
tell application "System Events"
	tell XML element 1 of contents of XML file XMLfile --tell <DAZzle> block
		set valuesListTotal to (count of XML elements)
		--Pull find and replace color values out of XML file and create a record list.
		repeat with thisElement from 1 to valuesListTotal
			set refIDFind to (value of (XML elements whose name is "ReferenceID") of XML element thisElement) as string
			set picFind to (value of (XML elements whose name is "PIC") of XML element thisElement) as string
			set theValuesList to theValuesList & {{refIDFind, picFind}}
		end repeat
	end tell
end tell

result:
{{“i0657”, “9101805213907328977972”}, {“i0648”, “9101805213907328977972”}, {“i0646”, “9101805213907328977972”}, {“i0641”, “9101805213907328977972”}, {“i0614”, “9101805213907328977972”}}

Model: iMac Intel 10.5.5
Browser: Firefox 3.0.2
Operating System: Mac OS X (10.5)

Thanks to both of you - I had utilized Adam’s solution and it met my needs. Haven’t examined the second solution yet.