Dear reader,
My problem du jour is that I am trying to parse an XML file so as to pull individual values from it and assign them to variables. The error I am getting is - Error location XMs/1: Can’t make “ESD MAC:FTP Server:Johnny Test:Inbox:Job Ticket_data.xml” into type integer. I don’t WANT an integer and for all I can see I am not asking for one, but then my XML skills are even less developed than my Applescript skills so maybe I am?
The following comes from my Queue Management script and is the step where the next job in the preprocessing queue gets kicked over to be run through preprocessing (checking for the existence of files, validating data, verifying users, etc.)
--> Running the preprocessing script
on sRunPreprocessing(lUserName, this_folder, lScriptsFolder, gPrefsFolder)
if (pPreProcTime ≥ (pPreProcTime + (30 * minutes))) or (pPriorityNo = 0 and pGeneralNo = 0) then -- 30 or more minutes or no other jobs in queue
set LoadPreprocessing to load script alias (lScriptsFolder & "Preprocessing.scpt" as Unicode text) -- Load Preprocessing script
tell LoadPreprocessing
sPreprocess(lUserName, this_folder, lScriptsFolder, gPrefsFolder) -- Run preprocessing script for next in queue
end tell
set pPreProcTime to time of (current date) -- Reset the clock to now
end if
end sRunPreprocessing
This next bit comes from the preprocessing script and is attempting to read the XML created from an Adobe Acrobat form in preparation to verify the customer / enter new information into a database record.
--> parse .XML file (unless I went cgi route)
set z to 3 -- Block marker
set LoadXMLParser to load script alias (lScriptsFolder & "XML Parser.scpt" as Unicode text)
tell LoadXMLParser
set lJobType to sGetItem(gInboxFolder, lXMLFileName, "PDFJobType")
set lUserName to sGetItem(gInboxFolder, lXMLFileName, "PDFContactName")
set lAddress to sGetItem(gInboxFolder, lXMLFileName, "PDFCustomerAddress")
set lCity to sGetItem(gInboxFolder, lXMLFileName, "PDFCustomerCity")
set lState to sGetItem(gInboxFolder, lXMLFileName, "PDFCustomerState")
set lZipCode to sGetItem(gInboxFolder, lXMLFileName, "PDFCustomerZip")
set lToAddress to sGetItem(gInboxFolder, lXMLFileName, "PDFCustomerEmail")
set lCCAddresses to sGetItem(gInboxFolder, lXMLFileName, "PDFCCEmailAddresses")
set lPriority to sGetItem(gInboxFolder, lXMLFileName, "PDFPriority")
end tell
This last bit is from my XML parser script and yes, I know it isn’t actually written to do what I need yet but it should, when I get it right, pull the value form the XML associated with lXMLLabel and assign it to a variable. Right now I would just be happy if I could get ANYTHING that indicated that data of ANY sort was being pulled from the XML File but all I seem to get are stupid integer errors. Any ideas on what I am doing wrong?
on sGetItem(gInboxFolder, lXMLFileName, lXMLLabel)
set lXMLPath to (gInboxFolder & lXMLFileName as Unicode text)
try
set y to "XMs" -- Script designator
set z to 1 -- Block marker
tell "XMLLib"
set lOpenXML to XMLOpen alias (gInboxFolder & lXMLFileName as Unicode text)
set lXMLRecord to XMLGetText lOpenXML as record
XMLClose lOpenXML
end tell
on error msg
display dialog "Error location " & y & "/" & z & ": " & msg with icon stop
end try
end sGetItem
Thanks in advance for any help rendered. I was also wondering, does anyone know where I can find some good acgi dispatcher tutorials or examples? The ones that came with aren’t helping me understand how to make it work.