本文整理汇总了PHP中tidy::ParseString方法的典型用法代码示例。如果您正苦于以下问题:PHP tidy::ParseString方法的具体用法?PHP tidy::ParseString怎么用?PHP tidy::ParseString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tidy
的用法示例。
在下文中一共展示了tidy::ParseString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputBody
/**
* 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();
}
}
}
示例2: validate
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();
}
}
}