Checking the Zend Framework Site Map

When I output Zend Navigation using sitemap() view a helper, I get the following error:

 Sitemap is invalid according to XML Schema at "http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 

Confirmation Included:

 $this->navigation()->setUseSchemaValidation(true)->setFormatOutput(true); 
  • How to display a valid XML sitemap using Zend Framework?

My site map looks like this:

 <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://example.com/index/index/slug/news</loc> </url> <url> <loc>http://example.com/strona/test-page</loc> </url> <url> <loc>http://example.com/strona/test-submenu</loc> </url> <url> <loc>http://example.com/strona/subpage-submenu</loc> </url> <url> <loc>http://example.com/strona/test-submenu-1</loc> </url> <url> <loc>http://example.com/feed/list</loc> </url> <url> <loc>http://example.com/default/sitemap</loc> </url> </urlset> 
+4
source share
1 answer

Premise:
DomDocument :: schemaValidate ($ path) will not work until allow_url_fopen is enabled

About Sitemaps:
From http://www.sitemaps.org/protocol.php#validating

To test your Sitemap or Sitemap Index File for a schema, an XML file will be required additionally as shown below.

 <?xml version='1.0' encoding='UTF-8'?> <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> ... </url> </urlset> 

To add these headers to your XML, you first need to get DomDocument via $domDoc = $this->sitemap()->getDomSitemap() than add additional headers and finally echo $domDoc->saveXml()

I don’t think I have done so much for you, you might need an additional subclass of ViewHelper Zend_View_Helper_Navigation_Sitemap.

Unfortunately, I have never worked with DomDocument before, so I cannot help with setting namespace attributes, maybe this post will help you with this.

+3
source

Source: https://habr.com/ru/post/1334722/


All Articles