DOM : special chars (entities) in attributes

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I currently use the DOM from PHP5 to create XHTML documents.
I have a problem with entities. I would like to create a node :
<input id="place" value="café rouge">
To do that I simply create the node with createElement, and then :
  $node -> setAttribute ("value", $val);
If I set $val = "café rouge", the saveXML causes PHP to fail with an
error message. The accentuated character seems to be a problem.
If I set $val = "caf&eacute; rouge", saveXML automatically replaces
the & with &amp; and that's not what I expect either.
Any idea ?

Re: DOM : special chars (entities) in attributes

On 13 Feb 2005 05:50:26 -0800, (Jamais-Content) wrote:

Quoted text here. Click to load it

 Perhaps the same as:

 i.e. you need to utf8 encode before passing to the DOM functions.

< Space: disk usage analysis tool

Re: DOM : special chars (entities) in attributes

Thanks with utf8_encode('café rouge') it works well !

Site Timeline