Connecting Tech Pros Worldwide Help | Site Map

DOM : special chars (entities) in attributes

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 11:29 AM
Jamais-Content
Guest
 
Posts: n/a
Default DOM : special chars (entities) in attributes

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

  #2  
Old July 17th, 2005, 11:29 AM
Andy Hassall
Guest
 
Posts: n/a
Default 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
  #3  
Old July 17th, 2005, 11:30 AM
Jamais-Content
Guest
 
Posts: n/a
Default Re: DOM : special chars (entities) in attributes

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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.