Magento file: lib/Zend/XmlRpc/Generator/DomDocument.php

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

Magento folder: lib/Zend/XmlRpc/Generator/
Magento file: lib/Zend/XmlRpc/Generator/DomDocument.php

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_XmlRpc
  17. * @subpackage Generator
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: DomDocument.php 20785 2010-01-31 09:43:03Z mikaelkael $
  21. */
  22. /**
  23. * @var Zend_XmlRpc_Generator_GeneratorAbstract
  24. */
  25. #require_once 'Zend/XmlRpc/Generator/GeneratorAbstract.php';
  26. /**
  27. * DOMDocument based implementation of a XML/RPC generator
  28. */
  29. class Zend_XmlRpc_Generator_DomDocument extends Zend_XmlRpc_Generator_GeneratorAbstract
  30. {
  31. /**
  32. * @var DOMDocument
  33. */
  34. protected $_dom;
  35. /**
  36. * @var DOMNode
  37. */
  38. protected $_currentElement;
  39. /**
  40. * Start XML element
  41. *
  42. * @param string $name
  43. * @return void
  44. */
  45. protected function _openElement($name)
  46. {
  47. $newElement = $this->_dom->createElement($name);
  48. $this->_currentElement = $this->_currentElement->appendChild($newElement);
  49. }
  50. /**
  51. * Write XML text data into the currently opened XML element
  52. *
  53. * @param string $text
  54. */
  55. protected function _writeTextData($text)
  56. {
  57. $this->_currentElement->appendChild($this->_dom->createTextNode($text));
  58. }
  59. /**
  60. * Close an previously opened XML element
  61. *
  62. * Resets $_currentElement to the next parent node in the hierarchy
  63. *
  64. * @param string $name
  65. * @return void
  66. */
  67. protected function _closeElement($name)
  68. {
  69. if (isset($this->_currentElement->parentNode)) {
  70. $this->_currentElement = $this->_currentElement->parentNode;
  71. }
  72. }
  73. /**
  74. * Save XML as a string
  75. *
  76. * @return string
  77. */
  78. public function saveXml()
  79. {
  80. return $this->_dom->saveXml();
  81. }
  82. /**
  83. * Initializes internal objects
  84. *
  85. * @return void
  86. */
  87. protected function _init()
  88. {
  89. $this->_dom = new DOMDocument('1.0', $this->_encoding);
  90. $this->_currentElement = $this->_dom;
  91. }
  92. }
`Reply Or Comment!
Please LogIn to Reply!