set('xml', new Helper_E2pdf_SimpleXMLElement('<' . $key . '>')); return $this->get('xml'); } /** * Get XML file in Base64 * * @return string */ public function get_xml() { if ($this->get('xml')) { return base64_encode($this->get('xml')->asXML()); } return ''; } /** * Set option * * @param string $key - Key of option * @param string $value - Value of option * * @return bool - Status of setting option */ public function set($key, $value) { if (!isset($this->xml)) { $this->xml = new stdClass(); } $this->xml->$key = $value; } /** * Get option by key * * @param string $key - Key to get assigned option value * * @return mixed */ public function get($key) { if (isset($this->xml->$key)) { return $this->xml->$key; } else { return false; } } /** * Get Element Attribute Value * * @param object $element - XML Element * @param string $attribute - Attribute Name * * @return string|bool */ public function get_node_value($element, $attribute = '') { $value = ""; if (is_object($element) && $attribute && isset($element->attributes) && $element->attributes->getNamedItem($attribute)) { $value = $element->attributes->getNamedItem($attribute)->nodeValue; } return $value; } /** * Check Element Attribute * * @param object $element - XML Element * @param string $attribute - Attribute Name * * @return string|bool */ public function check_node_value($element, $attribute = '') { if (is_object($element) && $attribute && isset($element->attributes) && $element->attributes->getNamedItem($attribute)) { return true; } return false; } /** * Set Element Attribute * * @param object $element - XML Element * @param string $attribute - Attribute Name * @param string $value - Attribute Value * @param bool $parent - if need to modify parent node * * @return object */ public function set_node_value($element, $attribute = '', $value = '', $parent = false) { if ($parent) { if (is_object($element) && $attribute && isset($element->parentNode->attributes)) { if ($element->parentNode->attributes->getNamedItem($attribute)) { $element->parentNode->attributes->getNamedItem($attribute)->nodeValue = $value; } elseif ($this->get('dom')) { $attr = $this->get('dom')->createAttribute($attribute); $attr->value = $value; $element->parentNode->appendChild($attr); } } } else { if (is_object($element) && $attribute && isset($element->attributes)) { if ($element->attributes->getNamedItem($attribute)) { $element->attributes->getNamedItem($attribute)->nodeValue = $value; } elseif ($this->get('dom')) { $attr = $this->get('dom')->createAttribute($attribute); $attr->value = $value; $element->appendChild($attr); } } } return $element; } }