Re: xmlspecialchars

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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... :-(


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux