Issue with parsing file with XML suite

Hi,

I am trying to create an XML version of a file using XML suite, and have run into an issue where the following works (modified from Bruce Phillips’ post in the Applescript RSS and Speech? thread):


set xmlFile to (choose file) as Unicode text

tell application "System Events"
	set titleValue to value of XML element "title" of XML element "channel" of XML element "rss" of contents of XML file xmlFile
	display dialog "the title is " & titleValue
end tell

but the code I want where a POSIX path is used to identify the file to process, rather than having the user select it through a dialog, shown below, does not work, even when the same file is processed in both cases:


set xmlFile to read file ("/valid/path/to/file/RSS.xml" as POSIX file)

tell application "System Events"
	set titleValue to value of XML element "title" of XML element "channel" of XML element "rss" of contents of XML file xmlFile
	display dialog "the title is " & titleValue
end tell

Running the second code snippet generates an NSReceiverEvaluatonScriptError. Can anyone shed any light on what the difference between output of the two selection processes is, and what I need to do to get the second code snippet working as expected!

I would try replacing that with this:

set xmlFile to read file (POSIX file "/valid/path/to/file/RSS.xml")

Unfortunately that did not work, however as soon as I set xmlFile to be a path reference, rather than holding the contents of the file, it worked:


set xmlFile to "/valid/path/to/file/RSS.xml"
tell application "System Events"
	set titleValue to value of XML element "title" of XML element "channel" of XML element "rss" of contents of XML file xmlFile
	display dialog "the title is " & titleValue
end tell