File indexing completed on 2024-12-22 05:37:14
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 * XML generator adapter based on XMLWriter 0030 */ 0031 class Zend_XmlRpc_Generator_XmlWriter extends Zend_XmlRpc_Generator_GeneratorAbstract 0032 { 0033 /** 0034 * XMLWriter instance 0035 * 0036 * @var XMLWriter 0037 */ 0038 protected $_xmlWriter; 0039 0040 /** 0041 * Initialized XMLWriter instance 0042 * 0043 * @return void 0044 */ 0045 protected function _init() 0046 { 0047 $this->_xmlWriter = new XMLWriter(); 0048 $this->_xmlWriter->openMemory(); 0049 $this->_xmlWriter->startDocument('1.0', $this->_encoding); 0050 } 0051 0052 0053 /** 0054 * Open a new XML element 0055 * 0056 * @param string $name XML element name 0057 * @return void 0058 */ 0059 protected function _openElement($name) 0060 { 0061 $this->_xmlWriter->startElement($name); 0062 } 0063 0064 /** 0065 * Write XML text data into the currently opened XML element 0066 * 0067 * @param string $text XML text data 0068 * @return void 0069 */ 0070 protected function _writeTextData($text) 0071 { 0072 $this->_xmlWriter->text($text); 0073 } 0074 0075 /** 0076 * Close an previously opened XML element 0077 * 0078 * @param string $name 0079 * @return void 0080 */ 0081 protected function _closeElement($name) 0082 { 0083 $this->_xmlWriter->endElement(); 0084 0085 return $this; 0086 } 0087 0088 public function saveXml() 0089 { 0090 $xml = $this->_xmlWriter->flush(false); 0091 return $xml; 0092 } 0093 }