Example #1
0
 /**
  * Echo the body segments
  *
  * @return void
  */
 public function outputBody()
 {
     $body = implode('', $this->_body);
     if (!$this->_enableTidy) {
         echo $body;
     } else {
         $tidy = new tidy();
         $tidy->ParseString($body, $this->_config, $this->_tidyEncoding);
         #$tidy->cleanRepair();
         if ($this->_echoTidyErrors && $tidy->errorBuffer) {
             echo $body;
             echo "\n\n\n<!--\n";
             echo "tidy detected the following errors:\n";
             echo $tidy->errorBuffer;
             echo "\n-->";
         } else {
             echo $tidy->root();
         }
     }
 }
Example #2
0
 public function validate()
 {
     $data = $this->A("RSSParserCache");
     libxml_use_internal_errors(true);
     $data = str_replace("<content:encoded>", "<contentEncoded>", $data);
     $data = str_replace("</content:encoded>", "</contentEncoded>", $data);
     echo htmlentities($data);
     try {
         $xml = new SimpleXMLElement($data);
     } catch (Exception $e) {
         try {
             $config = array('indent' => true, 'input-xml' => true, 'output-xml' => true, 'wrap' => false);
             $tidy = new tidy();
             $tidy->ParseString($data, $config, "utf8");
             $tidy->cleanRepair();
             #print_r($tidy."");
             $xml = new SimpleXMLElement($tidy . "");
         } catch (Exception $e) {
             echo "<pre>";
             echo "Exception: " . $e->getMessage() . "\n";
             foreach (libxml_get_errors() as $error) {
                 if ($error->level == LIBXML_ERR_WARNING) {
                     echo "Warning: " . $error->message;
                 }
                 if ($error->level == LIBXML_ERR_ERROR) {
                     echo "Error: " . $error->message;
                 }
                 if ($error->level == LIBXML_ERR_FATAL) {
                     echo "Fatal error: " . $error->message;
                 }
             }
             echo "</pre>";
             return array();
         }
     }
 }