Web 2.0 网站架构、优化 数据库架构

PHP+Tidy-完美的XHTML纠错+过滤

          function HtmlFix( $html ) {
		if (!function_exists('tidy_repair_string'))
			return $html;
			//repair
		$str = tidy_repair_string($html, array(
			'output-xhtml' => true
		), 'utf8');
		//parse
		$str = tidy_parse_string($str, array(
			'output-xhtml' => true
		), 'utf8');
		$s = '';
		$nodes = @tidy_get_body($str)->child;
		if (!is_array($nodes)) {
			$returnVal = 0;
			return $s;
		}
		foreach ($nodes as $n) {
			$s .= $n->value;
		}
		return $s;
	}

转载:http://hi.baidu.com/aohaiyixiao1/blog/item/c93ad9d3e364b6d5a8ec9a53.html

官方:http://tidy.sourceforge.net/

返回顶部