2

When I access the page of the following PHP code in IE, IE produces the error, "Internet Explorer does not support feeds with DTDs. This feed contains a DTD (Document Type Definition). ... ... DTDs are used to define a structure of a webpage. Internet Explorer does not support DTDs in feeds."

<?php 
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
?>          
<!DOCTYPE doctypeName [
   <!ENTITY nbsp "&#160;">
]>                  
<rss version="2.0">
<channel>
    <title>Sample Feed</title>
    <link>http://google.com</link>
    <description>This is a test</description>   
        <item>
            <title>Item</title>
            <description>This is the item.&nbsp;&nbsp;</description>
        </item>
</channel>      
</rss>

I suspect this part is the problem:

<!DOCTYPE doctypeName [
   <!ENTITY nbsp "&#160;">
]>  

But if I remove it, I get this error instead:

Reference to undefined entity 'nbsp'. Line: 10 Character: 36

This is the item.  

So it is necessary to allow &nbsp; in the description tag.

Any ideas?

Teno
  • 2,414
  • 3
  • 30
  • 54
  • Why do you need ` ` in the first place? It's not valid XML. If you need it inside your content, it's HTML content and you should put it in `CDATA` tags – Pekka Oct 18 '12 at 00:25
  • @Pekka `Why do you need   in the first place?` - It is an automatically generated content-feed in my actual program. So it gets inserted inevitably. – Teno Oct 18 '12 at 00:29

1 Answers1

2

&nbsp; is not valid XML. Using a DTD to make it valid is a terrible workaround.

If you need it in your content, that content is really HTML; in that case, you should either

  • wrap it in CDATA tags or
  • escape the ampersands into &amp;.

This question gives an overview over which method is better. Quentin's answer also contains another solution, using a XML library to create the markup. It may be overkill for your specific example, but it usually the best way to go.

Community
  • 1
  • 1
Pekka
  • 418,526
  • 129
  • 929
  • 1,058