Hey, I generated a sitemap with www.xml-sitemaps.com . I exported the xml file and when I uploaded it to my site it’s just this massive clump of text, there are no paragraph or breaks. I have seen other sitemaps which are just plain text, but there is at least a paragraph break between one <loc> and the other.
Is this just how it is or is there a way to fix it to at least make it slightly readable?
Sample file (with less items)
<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
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">
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
<url>
<loc>http://www.mydomain.com/</loc>
<lastmod>2010-07-05T13:30:04+00:00</lastmod>
</url>
<url>
<loc>http://www.mydomain.com/index.html</loc>
<lastmod>2010-07-05T13:30:04+00:00</lastmod>
</url>
</urlset>
The schema xsd stuff is regarding validation.
What you are talking about is human readability. eg. Instead of
<tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag><tag>
You would prefer
<tag>
<tag>
<tag>
<tag>
<tag>
<tag>
<tag>
<tag>
<tag>
<tag>
<tag>
<tag>
This has to do with whitespace - newlines.
It may be that the file actually doesn’t contain any. It isn’t needed for a file meant to be read by computers, and in fact, not having any can reduce file weight considerably. Much as javascript and CSS files can be compressed into minified files.
Or it may be that the code is using one type of newline and you are reading in another. i.e. Windows (CRLF) vs. UNIX (LF) vs. Mac (CR)
Try changing your text editor settings or using different text editors to view it.
Hey Alex, thanks for the feedback.
The code you provided still appears as one long line with no paragraph spacing between the <loc> elements. I’m saving this as sitemap.xml, but am I doing something wrong for this not to appear with any formatting?
http://www.mydomain.com/ 2010-07-05T13:30:04+00:00 http://www.mydomain.com/index.html 2010-07-05T13:30:04+00:00
Yes, you don’t need all of that junk in the header, below I’ve reformatted it so it’s less puffy and it’ll still work (and validate):
<?xml version="1.0" encoding="UTF-8"?>
[B]<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">[/B]
<url>
<loc>http://www.mydomain.com/</loc>
<lastmod>2010-07-05T13:30:04+00:00</lastmod>
</url>
<url>
<loc>http://www.mydomain.com/index.html</loc>
<lastmod>2010-07-05T13:30:04+00:00</lastmod>
</url>
</urlset>
PS: To make it more readable, you might need to manually add in the tabbed spacing (etc) or find a tool that can restructure the file. 