Exemplo n.º 1
0
 /**
  * @param  NodeInterface $node
  * @return $this
  */
 protected function writeInternal(NodeInterface $node)
 {
     $len = 1;
     if ($node->getAttributes() != null) {
         $len += count($node->getAttributes()) * 2;
     }
     if (count($node->getChildren()) > 0) {
         $len += 1;
     }
     if (strlen($node->getData()) > 0) {
         $len += 1;
     }
     $this->writeListStart($len);
     $this->writeString($node->getName());
     $this->writeAttributes($node->getAttributes());
     if (strlen($node->getData()) > 0) {
         $this->writeBytes($node->getData());
     }
     if ($node->getChildren()) {
         $this->writeListStart(count($node->getChildren()));
         foreach ($node->getChildren() as $child) {
             $this->writeInternal($child);
         }
     }
     return $this;
 }