views:

38

answers:

1

Hi,

I have created sitemap for my site using some reference code in the below link

http://stackoverflow.com/questions/2747801/creating-an-xml-sitemap-with-php

But I am getting error as

XML Parsing Error: undefined entity Location:

as my content is as follows

<< alt >> attribute and it says something like

< loc >http://www.example.com/700- & laquo;alt & raquo;-attributes-in-images.php< /loc >

Can anyone tell me how to get rid of this error.

A: 

I think you just have to use the urlencode() function on the link value and reconvert the entities before using html_entity_decode():

echo '<loc>'.urlencode(html_entity_decode($link)).'<loc>';

or something similar in your code.

Kau-Boy