My browser is telling me:
error on line 2 at column 308899: Entity 'ntilde' not defined
and the specific line is in my xml as:
<LastName>Treviño</LastName>
the name was originally Treviño
, but it was modified via php's htmlentities
function.
What can I do to get php and xml to play nicely?
Using Chrome 19 on Mac.
Apparently using htmlspecialchars
and htmlentities
in tandem does the trick.
htmlspecialchars(htmlentities($value));
Are you actually generating XML, or HTML? They're not the same thing. HTML defines a bunch of entities (IIRC) whereas XML has very few "built-in" - just a few like &
and <
.
Why both using the entity when you can just use the text directly? Simply make sure you're consistent about the encoding you use (UTF-8 would be a good bet).
You dont need to encode the tilde character in XML. It will throw errors. Best thing to do in this case might be to wrap the text in CDATA.
<LastName><![CDATA[Treviño]]></LastName>
Try to specify encoding for htmlentities
htmlentities($string,ENT_QUOTES,'UTF-8');