setValue() public method

public setValue ( $value )
Example #1
0
 public function testToString()
 {
     $element = new TXmlElement('tag');
     self::assertEquals('<tag />', (string) $element);
     $element->setAttribute('key', 'value');
     self::assertEquals('<tag key="value" />', (string) $element);
     $element->setValue('value');
     self::assertEquals('<tag key="value">value</tag>', (string) $element);
 }
Example #2
0
 /**
  * Recursively converts DOM XML nodes into TXmlElement
  * @param DOMXmlNode the node to be converted
  * @return TXmlElement the converted TXmlElement
  */
 protected function buildElement($node)
 {
     $element = new TXmlElement($node->tagName);
     $element->setValue($node->nodeValue);
     foreach ($node->attributes as $name => $attr) {
         $element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
     }
     foreach ($node->childNodes as $child) {
         if ($child instanceof \DOMElement) {
             $element->getElements()->add($this->buildElement($child));
         }
     }
     return $element;
 }