Connecting Tech Pros Worldwide Help | Site Map

DOM : special chars (entities) in attributes

Jamais-Content
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi,
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 ?
Thanks
Andy Hassall
Guest
 
Posts: n/a
#2: Jul 17 '05

re: DOM : special chars (entities) in attributes


On 13 Feb 2005 05:50:26 -0800, jamais.content@tele2.fr (Jamais-Content) wrote:
[color=blue]
>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 ?[/color]

Perhaps the same as:

http://groups-beta.google.com/group/...3c4f0d12e093fc

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

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jamais-Content
Guest
 
Posts: n/a
#3: Jul 17 '05

re: DOM : special chars (entities) in attributes


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


Similar PHP bytes