W3C验证器发出警告:未找到DOCTYPE!适用于Kohana 3 Feed Class

时间:2015-01-15 21:50:54

标签: xml validation rss kohana w3c

我使用以下Feed Class from Kohana 3.0代码创建RSS Feed。

class Controller_Feed extends Controller {

    public function action_best()
    {
        $info = array(
           "title" => "HYIP Monitor,
           "pubDate" => date("D, d M Y H:i:s T"),
           "description" => "Provides the best style of HYIP Rating.",
           "link" => "http://tophyips.info/",
           "copyright" => "TOPHYIPS.INFO",
           "language" => "en-us",
           "ttl" => "5",
        );

        $items = array();   
        $items[1] = array(
           "title" => "Best Rated Hyips Style-1",
           "link" => "http://tophyips.info/monitor/hyip-rating/style-1/best-1",
           "description" => "Best Monitoring Site Style#1",
           "guid" => "http://tophyips.info/monitor/hyip-rating/style-1/best-1",
        );

        $this->response->headers('Content-Type', 'text/xml; charset=utf-8');
        $this->response->body(Feed::create($info, $items));
    }

}//End File

在使用W3C进行验证时,您可以查看此链接:http://validator.w3.org/,结果表明该文档已成功检查为格式良好的XML!但有以下警告:

No DOCTYPE found! Checking XML syntax only.

The DOCTYPE Declaration was not recognized or is missing. This probably means that the Formal Public Identifier contains a spelling error, or that the Declaration is not using correct syntax, or that your XML document is not using a DOCTYPE Declaration.

请告知如何解决此警告。我将使用什么样的DOCTYPE声明以及将代码放在Kohana_Feed类文件中的位置。感谢。

1 个答案:

答案 0 :(得分:1)

W3C的Markup Validation Service适用于(X)HTML,MathML,SVG和SMIL文档。

要验证Feed,您应该使用W3C的Feed Validation Service

这不会为丢失的DOCTYPE生成警告,这在XML中是不必要的。