Overview

Packages

  • Jyxo_Beholder
  • Jyxo_Charset
  • Jyxo_Color
  • Jyxo_Css
  • Jyxo_ErrorHandling
  • Jyxo_FirePhp
  • Jyxo_Gettext
    • Parser
  • Jyxo_Html
  • Jyxo_Input
    • Chain
    • Filter
    • Validator
  • Jyxo_Mail
    • Email
    • Parser
    • Sender
  • Jyxo_Rpc
    • Json
    • Xml
  • Jyxo_Shell
  • Jyxo_SpamFilter
  • Jyxo_Spl
  • Jyxo_String
  • Jyxo_Svn
  • Jyxo_Time
  • Jyxo_Timer
  • Jyxo_Webdav
  • Jyxo_XmlReader
  • PHP

Classes

  • Jyxo_XmlReader
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * Jyxo PHP Library
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file license.txt.
 10:  * It is also available through the world-wide-web at this URL:
 11:  * https://github.com/jyxo/php/blob/master/license.txt
 12:  */
 13: 
 14: /**
 15:  * XMLReader child class (available since PHP 5.1).
 16:  *
 17:  * @category Jyxo
 18:  * @package Jyxo_XmlReader
 19:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
 20:  * @license https://github.com/jyxo/php/blob/master/license.txt
 21:  * @author Jaroslav HanslĂ­k
 22:  */
 23: class Jyxo_XmlReader extends XMLReader
 24: {
 25:     /**
 26:      * Text types list.
 27:      *
 28:      * @var array
 29:      */
 30:     private $textTypes = array(
 31:         self::TEXT => true,
 32:         self::WHITESPACE => true,
 33:         self::SIGNIFICANT_WHITESPACE => true
 34:     );
 35: 
 36:     /**
 37:      * Content types list.
 38:      *
 39:      * @var array
 40:      */
 41:     private $contentTypes = array(
 42:         self::CDATA => true,
 43:         self::TEXT => true,
 44:         self::WHITESPACE => true,
 45:         self::SIGNIFICANT_WHITESPACE => true
 46:     );
 47: 
 48:     /**
 49:      * Returns element's text contents.
 50:      *
 51:      * @return string
 52:      */
 53:     public function getTextValue()
 54:     {
 55:         $depth = 1;
 56:         $text = '';
 57: 
 58:         while ((0 !== $depth) && ($this->read())) {
 59:             if (isset($this->textTypes[$this->nodeType])) {
 60:                 $text .= $this->value;
 61:             } elseif (self::ELEMENT === $this->nodeType) {
 62:                 if (!$this->isEmptyElement) {
 63:                     $depth++;
 64:                 }
 65:             } elseif (self::END_ELEMENT === $this->nodeType) {
 66:                 $depth--;
 67:             }
 68:         }
 69:         return $text;
 70:     }
 71: 
 72:     /**
 73:      * Returns element's contents including tags.
 74:      *
 75:      * @return string
 76:      */
 77:     public function getContent()
 78:     {
 79:         $depth = 1;
 80:         $text = '';
 81: 
 82:         while ((0 !== $depth) && ($this->read())) {
 83:             if (isset($this->contentTypes[$this->nodeType])) {
 84:                 $text .= $this->value;
 85:             } elseif (self::ELEMENT === $this->nodeType) {
 86:                 if ($this->isEmptyElement) {
 87:                     $text .= '<' . $this->name . '/>';
 88:                 } else {
 89:                     $depth++;
 90:                     $text .= '<' . $this->name;
 91: 
 92:                     while ($this->moveToNextAttribute()) {
 93:                         $text .= ' ' . $this->name . '="' . $this->value . '"';
 94:                     }
 95: 
 96:                     $text .= '>';
 97:                 }
 98:             } elseif (self::END_ELEMENT === $this->nodeType) {
 99:                 $depth--;
100:                 if ($depth > 0) {
101:                     $text .= '</' . $this->name . '>';
102:                 }
103:             }
104:         }
105: 
106:         return $text;
107:     }
108: }
109: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0