Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a site map with generated dynamic urls that I need included in the sitemap. However, the sitemap seems to be generating an error on the & character, so that pages with more than one variable in the query string break the sitemap. How can I fix this? Here's an example:

http://example.com/index.php?action=view&id=10
share|improve this question

1 Answer 1

up vote 6 down vote accepted

The ampersand (&) character is a reserved character in XML (sitemaps are XML) and must be replaced with an XML entity that represents it. In this case that would be & (all entities start with ampersand which is why it is reserved).

When the XML is parsed the & entity in your url will be translated into plain &.

share|improve this answer
    
Note that if you're generating the URL through PHP, run the entire URL string through the htmlentities function to solve this problem. (php.net/manual/en/function.htmlentities.php) –  Virtuosi Media Aug 28 '10 at 20:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.