Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old Dec 18, 2012, 03:39 PM   #1
moonman239
macrumors 6502a
 
Join Date: Mar 2009
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:

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
When I try to run this code, I get the error "Can't get every element of {} whose name = "subviews"". I just don't get why the fourth line of code results in tableViewCells being set to nothing useful. The tag names are correct.

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.
moonman239 is offline   0 Reply With Quote

 
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC