public function setOption($name, $value) { $xmlOptions = XmlHelper::getChildNode($this->xml, "options"); $lstOptions = $xmlOptions->childNodes; // look for option, set, exit foreach ($lstOptions as $xmlOption) { if ($xmlOption->getAttribute("name") == $name) { XmlHelper::setValue($xmlOption, $value); return; } } // add new option if not found $xmlNewOption = $this->xml->ownerDocument->createElement("option", ""); $xmlNewOption->setAttribute("name", $name); $xmlOptions->appendChild($xmlNewOption); }
public function setOption($name, $value) { $xmlOptions = XmlHelper::getNode($this->xml, "options"); $lstOptions = $xmlOptions->childNodes; // search for option, if found, set & exit if ($lstOptions != null) { foreach ($lstOptions as $xmlOption) { if ($xmlOption->getAttribute("name") == $name) { XmlHelper::setValue($xmlOption, $value); return; } } } // create new option $xmlNewOption = $this->xml->ownerDocument->createElement("option"); $xmlNewOption->setAttribute("name", $name); XmlHelper::setValue($xmlNewOption, $value); $xmlOption->appendChild($xmlNewOption); return ""; }