Reputation: 2621
I want to generate an xml page in php but I found the problem at decoding / encoding special characters for example ""é""
myCode :
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc> é test è </loc>
<priority>1.000</priority>
<changefreq>always</changefreq>
</url>
</urlset>
but i get this message
This page contains the following errors:
error on line 4 at column 19: Entity 'eacute' not defined
Below is a rendering of the page up to the first error.
Upvotes: 1
Views: 3413
Reputation: 46778
The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
Use this instead
<loc>&eacute; test &egrave;</loc>
The &
must be encoded as &
OR use it within a CData section. It says that the following text isn't markup, but it character data instead.
<loc><![CDATA[é test è]]></loc>
Upvotes: 1
Reputation: 19377
Do you mean you want to put HTML entities in your XML or literal characters in your XML?
The only entities defined by XML are:
Nothing else. And only the first two are strictly necessary to represent any Unicode text in an XML document. It's perfectly OK to include literal >
, '
and "
in XML text.
To include literal characters in your XML document, just put them in there, and ensure that the encoding you use to produce the document in bytes format is the same as what is in the declaration. There are certain character classes that must be respected in element and attribute names, and you must still remember to use the & and < entities instead of the literals.
http://www.w3schools.com/xml/xml_encoding.asp
Upvotes: 1