You can use a small snippet of Perl code to easily convert unix time to a human readable format. As Perl is pre-installed on all modern Macs, it’s safe to use:
on run
-- unixtime
set uts to "1293940068"
set datestr to my getdatestr(uts)
display dialog datestr
end run
on getdatestr(uts)
set snippet to "perl -e 'print scalar(gmtime(" & uts & ")), \"\\n\"'"
set datestr to do shell script snippet
return datestr
end getdatestr
I convinced the System Events app to parse your XML using the following code (I saved your XML to a file):
set xmlfilepath to "/Users/martin/Desktop/test.xml"
tell application "System Events"
tell contents of XML file xmlfilepath
tell XML element 1
tell XML element "success"
set resetdate to value of XML attribute "resetdate"
set remaining to value of XML attribute "remaining"
end tell
end tell
end tell
end tell
Thanks Martin, but I have one problem.
I need to make the script save the XML data to a XML file, but my problem is that it isn’t saving and isn’t reading the file when it’s saved manually. I looked up on it, but all the websites said is that Applescript doesn’t work well with saving XML data to .xml files. Do you have any solutions?
I found my problem by having cURL output it’s data to a file, and having Applescript reading it. Thank you, everything now works. I’m going to work on everything else based on the new data extracted from the XML file.