Connecting Tech Pros Worldwide Forums | Help | Site Map

XML Entity Functions

Chung Leong
Guest
 
Posts: n/a
#1: Jul 17 '05
How come there isn't a xmlspecialchars(), and for that matter,
xml_entity_decode()? I would think someone would have thought of that by
now.



Eric Bohlman
Guest
 
Posts: n/a
#2: Jul 17 '05

re: XML Entity Functions


"Chung Leong" <chernyshevsky@hotmail.com> wrote in
news:YtudncTw97RIlJPdRVn-jw@comcast.com:
[color=blue]
> How come there isn't a xmlspecialchars(), and for that matter,
> xml_entity_decode()? I would think someone would have thought of that by
> now.[/color]

Probably because the only reserved characters (and the only ones with
predefined entities) in XML are the ones handled by htmlspecialchars().
Remember that unless a DTD defines further entities, the only character
entity names available in XML are &amp;, &lt;, &gt;, &quot;, and &apos;.
John Dunlop
Guest
 
Posts: n/a
#3: Jul 17 '05

re: XML Entity Functions


Eric Bohlman wrote:
[color=blue]
> "Chung Leong" <chernyshevsky@hotmail.com> wrote in
> news:YtudncTw97RIlJPdRVn-jw@comcast.com:
>[color=green]
> > How come there isn't a xmlspecialchars(), and for that matter,
> > xml_entity_decode()?[/color]
>
> Probably because the only reserved characters (and the only ones with
> predefined entities) in XML are the ones handled by htmlspecialchars().[/color]

OK. But in the case of html_entity_decode, it obviously won't work
for &apos;, since no such entity reference exists in HTML. That
entity reference will be left unchanged. No great problem though.

--
Jock
Chung Leong
Guest
 
Posts: n/a
#4: Jul 17 '05

re: XML Entity Functions


htmlspecialchars() doesn't do &apros; though. It's easy enough to use
strtr(), but if the string is of multi-byte encoding, then it might not work
(the second byte of a 2-byte character would be <>&"', but shouldn't be
replaced).

Uzytkownik "Eric Bohlman" <ebohlman@earthlink.net> napisal w wiadomosci
news:Xns9477D2C4745Bebohlmanomsdevcom@130.133.1.4. ..[color=blue]
> "Chung Leong" <chernyshevsky@hotmail.com> wrote in
> news:YtudncTw97RIlJPdRVn-jw@comcast.com:
>[color=green]
> > How come there isn't a xmlspecialchars(), and for that matter,
> > xml_entity_decode()? I would think someone would have thought of that by
> > now.[/color]
>
> Probably because the only reserved characters (and the only ones with
> predefined entities) in XML are the ones handled by htmlspecialchars().
> Remember that unless a DTD defines further entities, the only character
> entity names available in XML are &amp;, &lt;, &gt;, &quot;, and &apos;.[/color]


Closed Thread