There is an easier way than this, it located nodes and stuff in an xml and doesn't require defining variables.
There is also loops, that fly through all the nodes and search for a certain attribute and attribute value, this is used in some of the popular themes like StarHero and MonteHero, and is easy to do once you get the grasp of it.