File indexing completed on 2025-05-04 05:28:32
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_XmlRpc 0017 * @subpackage Generator 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @var Zend_XmlRpc_Generator_GeneratorAbstract 0025 */ 0026 // require_once 'Zend/XmlRpc/Generator/GeneratorAbstract.php'; 0027 0028 /** 0029 * DOMDocument based implementation of a XML/RPC generator 0030 */ 0031 class Zend_XmlRpc_Generator_DomDocument extends Zend_XmlRpc_Generator_GeneratorAbstract 0032 { 0033 /** 0034 * @var DOMDocument 0035 */ 0036 protected $_dom; 0037 0038 /** 0039 * @var DOMNode 0040 */ 0041 protected $_currentElement; 0042 0043 /** 0044 * Start XML element 0045 * 0046 * @param string $name 0047 * @return void 0048 */ 0049 protected function _openElement($name) 0050 { 0051 $newElement = $this->_dom->createElement($name); 0052 0053 $this->_currentElement = $this->_currentElement->appendChild($newElement); 0054 } 0055 0056 /** 0057 * Write XML text data into the currently opened XML element 0058 * 0059 * @param string $text 0060 */ 0061 protected function _writeTextData($text) 0062 { 0063 $this->_currentElement->appendChild($this->_dom->createTextNode($text)); 0064 } 0065 0066 /** 0067 * Close an previously opened XML element 0068 * 0069 * Resets $_currentElement to the next parent node in the hierarchy 0070 * 0071 * @param string $name 0072 * @return void 0073 */ 0074 protected function _closeElement($name) 0075 { 0076 if (isset($this->_currentElement->parentNode)) { 0077 $this->_currentElement = $this->_currentElement->parentNode; 0078 } 0079 } 0080 0081 /** 0082 * Save XML as a string 0083 * 0084 * @return string 0085 */ 0086 public function saveXml() 0087 { 0088 return $this->_dom->saveXml(); 0089 } 0090 0091 /** 0092 * Initializes internal objects 0093 * 0094 * @return void 0095 */ 0096 protected function _init() 0097 { 0098 $this->_dom = new DOMDocument('1.0', $this->_encoding); 0099 $this->_currentElement = $this->_dom; 0100 } 0101 }