|Dec 18, 2012, 04:39 PM||#1|
AppleScript: Set variable to every XML element of a given name
Dear fellow AppleScript programmers,
I have an iOS app that has recipes. Each recipe can be organized by course or by cuisine. Each course and cuisine have their own table view and controller. I need to make sure each recipe is linked to a course and cuisine. Since a storyboard is really an XML file containing all the UI elements, I figured I could create an AppleScript that searches all the table view cells to make sure that all recipes are linked to two table view cells.
Here is my code:
set the_file to ((choose file without invisibles) as string) tell application "System Events" set xml_data to contents of XML file the_file tell xml_data to set tableViewCells to every XML element of xml_data whose name is "tableViewCell" tell xml_data to set subViews to every XML element of tableViewCells whose name is "subviews" tell xml_data to set viewLinks to every XML element of subViews whose name is "view" tell xml_data to set viewControllers to every XML element whose name is "viewController" tell xml_data to set views to every XML element of viewControllers whose name is "view" tell xml_data to set navItems to first XML element of views whose name is "navigationItem" tell xml_data to set recipes to value of XML attribute "title" of XML element navItems end tell
I could do the job myself, but I just don't want to.
The funny thing about this signature is that by the time you get to the end of it, you will have spent between five and ten seconds doing so.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|String and variable concatenation in AppleScript||tekboi||Mac Programming||6||Apr 15, 2014 02:37 PM|
|Applescript newb: declaring a variable in another script.||Vanilla Face||Mac Programming||2||Jan 5, 2014 08:39 PM|
|How to set environmental variable?||hajime||Mac Basics and Help||3||Sep 28, 2013 10:33 PM|
|How do I set the position of an element relative to another element?||moonman239||Web Design and Development||3||Mar 3, 2013 05:30 PM|
|(AppleScript) "Tell"-ing every XML element to do something||moonman239||Mac Programming||2||Jan 3, 2013 05:06 PM|
All times are GMT -5. The time now is 12:55 PM.