3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\XmlRpc\Generator
;
13 * DOMDocument based implementation of a XML/RPC generator
15 class DomDocument
extends AbstractGenerator
25 protected $currentElement;
33 protected function _openElement($name)
35 $newElement = $this->dom
->createElement($name);
37 $this->currentElement
= $this->currentElement
->appendChild($newElement);
41 * Write XML text data into the currently opened XML element
45 protected function _writeTextData($text)
47 $this->currentElement
->appendChild($this->dom
->createTextNode($text));
51 * Close an previously opened XML element
53 * Resets $currentElement to the next parent node in the hierarchy
58 protected function _closeElement($name)
60 if (isset($this->currentElement
->parentNode
)) {
61 $this->currentElement
= $this->currentElement
->parentNode
;
66 * Save XML as a string
70 public function saveXml()
72 return $this->dom
->saveXml();
76 * Initializes internal objects
80 protected function _init()
82 $this->dom
= new \
DOMDocument('1.0', $this->encoding
);
83 $this->currentElement
= $this->dom
;