You are here: Re: How do I make & a literal character in an XML parse? « PHP Programming Language « IT news, forums, messages
Re: How do I make & a literal character in an XML parse?

Posted by Rik on 06/24/06 10:13

Bart Van der Donck wrote:
> Ivan Marsh wrote:
>
>> The XML my PHP app is returning to my JavaScript function has
>> elements in it that contain special characters... specifically the
>> ampersand & which hoses up the data. ex: Company Name = "K & B
>> Construction".
>>
>> Can anyone give me some idea of how I make the data coming out of my
>> database translate as literal characters in the XML output?
>
> I think you should deal with this at the PHP side because '&' is
> reserved for the declaration of entities. The best way is to encode
> your special chars to html entities before adding them to the XML
> file. I'ld say that PHP should have ready-to-go regexes for this kind
> of
> things.

There is, htmlentities().
Unfortunately, it doesn't recognize every character, and coverts the
ampersand in already converted entitities. In the comments, someone claims
to have written a better function for it:
http://www.prolifique.com/entities.php.txt

I haven't tried the code yet, maybe it's usefull here.

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация