开发者

Convert only certain xml characters to their HTML entities (&#nnn;)

开发者 https://www.devze.com 2022-12-09 07:35 出处:网络
I have a problem where I have some html like this <p>There is the unfinished business of Taiwan, event开发者_开发知识库ual “reunification”...a communiqué committing</p>

I have a problem where I have some html like this

<p>There is the unfinished business of Taiwan, event开发者_开发知识库ual “reunification”...a communiqué committing</p>

In that text string I would not want to change the < and > to & lt ; and ^ gt ;

However I would want to convert the quotes around “reunification” and the é in communiqué.


You will likely have to write your own htmlentities() replacement function. The easiest way would probably be to apply htmlentities(), and then replace < (or the numeric one, can't remember which php gives) with a <, and whatever other characters you want.

You might also be interested in Markdown, it is similar to what you are trying to accomplish, and might fit your needs.

http://daringfireball.net/projects/markdown/
http://michelf.com/projects/php-markdown/


'<' is a reserved character in XML. Section 2.3 of the XML standard strictly dictates that it MUST be escaped as either an entity or a character reference when used within character data. It is only allowed to appear in its unescapsed form when used as XML markup, or within a comment, processing instruction, or a CDATA section. Why do you want to bypass that requirement?

0

精彩评论

暂无评论...
验证码 换一张
取 消