public function setVar($variableName) { $element = $this->getDirectChild($variableName); if ($element) { $setter = 'set' . ucfirst($variableName); $value = $element->nodeValue; if (method_exists($this, $setter)) { $this->{$setter}($value); } } }