original_string: public function toXml($addCdata = true, $dtd = false, $version = '1.0')
      {
          $this->_prepareData();
  
          $xml    = new Xml(['version' => $version]);
          $root   = $xml->createElement('root');
          $xml    = $this->_arrayToXml($this->toArray(), $xml, $addCdata, $root);
  
          $xml->appendChild($root);
  
          if ($dtd) {
              $dtd = "<!DOCTYPE root SYSTEM '$dtd'>";
          }
  
          $xml->formatOutput = true;
          $xmlData = $xml->saveXmlFile(false, true);
  
          if ($xml->hasErrors()) {
              $this->_hasErrors       = true;
              $this->_errorsList[]    = $xml->getError();
              return false;
          }
  
          return $dtd . $xmlData;
      }
code: public function toXml($addCdata = true, $dtd = false, $version = '1.0')
      {
          $this->_prepareData();
  
          $xml    = new Xml(['version' => $version]);
          $root   = $xml->createElement('root');
          $xml    = $this->_arrayToXml($this->toArray(), $xml, $addCdata, $root);
  
          $xml->appendChild($root);
  
          if ($dtd) {
              $dtd = "<!DOCTYPE root SYSTEM '$dtd'>";
          }
  
          $xml->formatOutput = true;
          $xmlData = $xml->saveXmlFile(false, true);
  
          if ($xml->hasErrors()) {
              $this->_hasErrors       = true;
              $this->_errorsList[]    = $xml->getError();
              return false;
          }
  
          return $dtd . $xmlData;
      }
code_tokens: public function toXml ( $ addCdata = true , $ dtd = false , $ version = '1.0' ) { $ this -> _prepareData ( ) ; $ xml = new Xml ( [ 'version' => $ version ] ) ; $ root = $ xml -> createElement ( 'root' ) ; $ xml = $ this -> _arrayToXml ( $ this -> toArray ( ) , $ xml , $ addCdata , $ root ) ; $ xml -> appendChild ( $ root ) ; if ( $ dtd ) { $ dtd = "<!DOCTYPE root SYSTEM '$dtd'>" ; } $ xml -> formatOutput = true ; $ xmlData = $ xml -> saveXmlFile ( false , true ) ; if ( $ xml -> hasErrors ( ) ) { $ this -> _hasErrors = true ; $ this -> _errorsList [ ] = $ xml -> getError ( ) ; return false ; } return $ dtd . $ xmlData ; }
docstring: return object data as xml representation
  
  @param bool $addCdata
  @param string|boolean $dtd
  @param string $version
  @return string
docstring_tokens: return object data as xml representation