Hey everyone -
It's been a while since I've visted the DW forums, and I hope everyone is doing well.
I'm trying to create an XML sitemap for my personal blog. I've tried the built-in XML sitemap generator in DWCS5, but that sitemap seems to be more for collaboration than search engines. I then tried an online XML generator, added the generated text to DW, saved it as .xml and uploaded the file. Everything looks okay, but the file won't validate, and I get the feeling I'm supposed to be adding something to the generated content. I've searched and searched but I'm not familiar at all with XML or Schema so I haven't found an answer yet.
The xml file starts with the header from DW:
<?xml version="1.0" encoding="utf-8"?>
The next lines are from the online generator:
<urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!--created with Free Online Sitemap Generator www.xml-sitemaps.com -->
Obviously there are quite a few more entries but they're all the same so they've been left out for brevity.
The error that shows up most often in the validator is:
Fatal Error: undeclared attribute prefix in: xsi:schemaLocation
At line 3, column 128
.9/sitemap.xsd">?<!--? created with Free
with the closing tag after the .xsd" highlighted in yellow. There's a question mark in the error that's not in the commented-out text - maybe that's a clue?
I keep adding and subtracting text from the first urlset xsi link and another error that sometimes comes up is:
Incorrect http header content-type: "text/html" (expected: "application/xml")
What am I missing? I searched the forum but found surpringly few threads, so maybe it's something simple?
Thanks for your time.
Use the online XML sitemap generator below. Validation is not necessary.
Keep in mind, XML sitemaps are for search engine crawlers only, not fit for human consumption. For learning XML, see links below.
XML Validation - https://www.xmlvalidation.com/
XML Tutorial - https://www.w3schools.com/xml/
If you want a sitemap for humans, use HTML instead of XML.
Post back if you still have questions.
Thanks for your reply.
The XML generator is where the posted example above came from, and as mentioned, the reason for not using the DW sitemap is because it seemed to be geared towards human collaboration instead of search engines.
Why wouldn't an XML file need to be validated?
The sitemap generator does exactly what it needs to do. Trust the code. Besides, the validation in outdated CS5 was for HTML only, not XML.
Sorry - totally my fault for not being more specific-
I didn't use the DWCS5 sitemap so wasn't using the DW validator. I added the code generated from XML-Sitemaps to a DW page and saved it as an XML file with DW, but the included code came from XML-Sitemaps.
I tested the sitemap using the W3C validator and the XML-sitemaps validators. The XML-Sitemaps validation failure was a surprise because that's where the code came from.
If you care to post the XML code exactly as generated by the online sitemap generator, I'll look at it and tell you if it's valid XML syntax or not.
The W3C markup validation service is not suitable for checking XML because it's an HTML code checker.
Thanks - The posted XML code from the XML-Sitemaps generator is verbatim. Only the URLs have been changed.
There's nothing technically wrong with your sitemap except that it's incomplete. And if you're on a secure HTTPS server, you probably want to use links with HTTPS instead of HTTP for consistency.
This is the format I use.
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> <url> <loc>https://example.com/</loc> <lastmod>2020-06-04</lastmod> <changefreq>weekly</changefreq> <priority>0.8</priority> </url> <url> <loc>https://example.com/index.php</loc> <lastmod>2020-06-04</lastmod> <changefreq>weekly</changefreq> <priority>0.8</priority> </url> <url> <loc>https://example.com/page2.php</loc> <lastmod>2020-06-04</lastmod> <changefreq>monthly</changefreq> <priority>0.5</priority> </url> </urlset>
It's a personal blog site so none of the posts ever get modified once they've been posted, which is why I opted not to include
when generating the code.
Your code uses the xmlns in the urlset code - I tried that but don't remember if it was in the same order as yours. I'll try again later.
Thanks again for posting.