You are here: Re: [PHP] xmlspecialchars « PHP « IT news, forums, messages
Re: [PHP] xmlspecialchars

Posted by Jochem Maas on 12/28/05 13:19

Richard Lynch wrote:
> I'm creating some XML data, but not using any of the built-in PHP XML
> functions, as they are not necessarily available on all servers.
>
> I need to encode Data (CDATA) such as URLs etc.
>
> htmlspecialchars() works on all my test cases so far, but is it
> "right"?...

I don't think so - not completely - actually this is shaky ground for
me but one I'm very interested in (encoding/charsets/etc).

I'm pretty sure you can do this for example:

<sometag>
<![CDATA[<em>This is <a href="www.iamjochem.com/?i=1&amp;j=2">HTML</a></em>]]>
</sometag>

now I don't think that an XML parser will care if the href attribute's value is
encoded properly (e.g. the '&' given as '&amp;') because the whole CDATA block
is just a string (UTF8 is the default everywhere I have played with XML, so beware
that if you don't specify your character encoding that ti might cause hiccups).
so in the case above wether you entity encoding the url or not is pureluy a matter
of how valid do you want the HTML that one can extract from the CDATA block
inside the <sometag> tag.

the following urls might throw some light on the issue for you:

http://xmlrpc-epi.sourceforge.net/main.php?t=samples
http://blogs.law.harvard.edu/tech/encodingDescriptions

>
> Please cc: me on replies -- I'm way behind on PHP General reading... :-(
>

 

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

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