/**
  * Serialize
  *
  * @param   var value
  * @return  string
  */
 public function serialize($payload)
 {
     $t = new Tree();
     $t->setEncoding('UTF-8');
     if ($payload instanceof Payload) {
         $root = isset($payload->properties['name']) ? $payload->properties['name'] : 'root';
         $payload = $payload->value;
     } else {
         $root = 'root';
     }
     if ($payload instanceof Generic || is_array($payload)) {
         $t->root = Node::fromArray($this->convert($payload), $root);
     } else {
         $t->root = new Node($root, $this->convert($payload));
     }
     return $t->getDeclaration() . "\n" . $t->getSource(INDENT_NONE);
 }
 /**
  * Set XML from a tree
  *
  * @param   xml.Tree xml
  */
 public function setXMLTree(Tree $xml)
 {
     libxml_get_last_error() && libxml_clear_errors();
     $this->document = new DOMDocument();
     $this->document->loadXML($xml->getDeclaration() . $xml->getSource(INDENT_NONE));
     $this->_checkErrors($xml);
 }
Ejemplo n.º 3
0
 /**
  * Returns the full XML source of the 'dia' diagram
  *
  * @return  string XML representation of the DIAgramm
  */
 public function getSource($indent = INDENT_DEFAULT)
 {
     $Node = $this->getNode();
     $Tree = new Tree();
     $Tree->root = $Node;
     return $Tree->getDeclaration() . "\n" . $Tree->getSource($indent);
 }