Hi everyone,
I was wondering how to do a validation using an XML data file. To start off, here is the XML data feed I would like to cross check.
I am prompting the user to type in the file code which is either FS01 or FS02. Currently I have my AppleScript working fine if you type in either of those values however if the user incorrectly types a code that isn't in the XML feed, I would like the display dialog to repeat. Currently if the FileCode is not found, the AppleScript stops working until you compile the script again inside the application.
Here is part of my current AppleScript.
I then use the FileDescription and FileName to display a confirmation dialog to then trigger the graphic.
Cheers,
David
I was wondering how to do a validation using an XML data file. To start off, here is the XML data feed I would like to cross check.
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<GFX xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FS01>
<Description>Example Image 1</Description>
<FileName>FS01.png</FileName>
</FS01>
<FS02>
<Description>Example Image 2</Description>
<FileName>FS02.png</FileName>
</FS02>
I am prompting the user to type in the file code which is either FS01 or FS02. Currently I have my AppleScript working fine if you type in either of those values however if the user incorrectly types a code that isn't in the XML feed, I would like the display dialog to repeat. Currently if the FileCode is not found, the AppleScript stops working until you compile the script again inside the application.
Here is part of my current AppleScript.
Code:
set FileCode to text returned of (display dialog "ENTER FILE CODE" with title "DISPLAY GRAPHIC" default answer " ")
tell application "System Events"
set xmlData to contents of XML file "Users/####/Desktop/GFXLookup.xml"
tell XML element "GFX" of xmlData
tell XML element FileCode
set FileDescription to value of XML element "Description"
set FileName to value of XML element "FileName"
end tell
end tell
end tell
I then use the FileDescription and FileName to display a confirmation dialog to then trigger the graphic.
Cheers,
David