looping through an array/list returned from xmlrpc

I wrote a XML-RPC server in PHP that runs on my webserver. I use this to connect to a MySQL database and SELECT/INSERT/UPDATE data which is then queried to populate the content of my webpages on my homepage. This XML-RPC server lets me update my blog from my desktop, but I have a certain knowledge deficit at this point in regard to working with the data that is returned from the XML-RPC server.

this is the format of what is returned as a response:

[code]<?xml version="1.0"?>

id17 contentTypetext/html pagetitleMy Great Page longtitleWelcome to my great page aliasmypage.html parent0 content


isn't this a great page of content!

template6 createdon1144904400 editedby1 editedon1165209999 menutitle[*loginName*] [/code] So I understand how to set the value of a variable to the return of an xmlrpc call when it is a single item, but I cannot figure out how to work with this list. I read over the documentation on applescript lists, and I think i understand compound lists and records (I think records are like an associative array in php?) Basically, I guess I need to get each one of the above "members" into a separate variable, or into an associative record like this:

{{name:"id",value:"17"}{name:"contentType",value:"text/html"}{name:"pagetitle",value:"My Great Page"}{etc...}}

Any suggestions from some more experienced scripters? I am just beginning AppleScript, but already I am in love. It is much more powerful than I thought it could be.

Thanks in advance,

Dr. Scotty Delicious, Scientist.

I should mention, my AppleScript call to the xmlrpc server looks like this:

		set myUser to contents of text field "userField" of window "preferences"
		set myPass to contents of text field "passField" of window "preferences"
		set myHost to contents of text field "hostField" of window "preferences"
		set pageID to contents of text field "pageField" of window "main"
		set myMethod to title of current menu item of popup button "methodSelect" of window "main"
		set xmlRpcApp to myHost  & "/xmlrpc.php"
		using terms from application "http://www.xmlrpc.com/spec"
			tell application xmlRpcApp
				set pageContent to call xmlrpc {method name:myMethod, parameters:{myUser, myPass, pageID}}
			end tell
		end using terms from


Dr. Scotty Delicious, Scientist.

It seems that AppleScript is much smarter than me and is already placing the “members” in a list.
I think the problem I am having is that I can’t seem to figure out how to access any of the information.
I tried putting this in my AppleScript (in the tell application xmlRpcApp block)to no avail.

set returnArray to call xmlrpc {method name:"method.getArray", parameters:{myUser, myPass, myParam}}
display dialog (item 1 of returnArray)

but I get an error:
AppleScript Error:

any suggestions at all are appreciated.
I will try to just keep playing with it until I get a solid feel for AppleScript.

Dr. Scotty Delicious, Scientist.

Hallo Scotty,

this means, the result you received is of type ‘record’ - all items of it have their own key : ‘lidl’,‘contentType’,‘pageTitle’ and so on. In Applescript it is not possible to access the items of a record by it’s index:
‘get item n of myrecord’ always leads to an error. You can use ‘get lidl of myrecord’ or ‘get contenttype of myrecord’ instead.

If you want to have it converted to an Applescript list (NSArray) then you could use one of NSDictionary’s methods:

set theValues to call method "allValues" of myRecord

in theValues all keys are gone (it is a list) and you can access the information by an index variable.

If you are not sure about the result and/or your result has variable keys, you can get a list of the keys with an other NSDicitionary method:

set theKeys to call method "allKeys" of myRecord

Hope that helps, …

kind regards,


Thank you Dominik,
That is a HUGE clarification for me on how to work with lists and records. The AppleScript documentation at developer.apple.com left me more confused than when I started looking there, and with more questions.

I generally am not looking for someone else to flat out give me the solution to my program, so I really appreciate that you explained the techniques of accessing the data in lists and records as well as defining some of the core differences between lists and records for me without just saying “do this… then do this…”. Much gratitude for your taking the time to explain to a noob.


Dr. Scotty Delicious, Scientist.