Convert character entities to their unicode equivalents

前端 未结 4 1495
夕颜
夕颜 2020-12-16 15:53

I have html encoded strings in a database, but many of the character entities are not just the standard & and <. Entities like

4条回答
  •  無奈伤痛
    2020-12-16 16:05

    you can download a local copy of the appropriate HTML and/or XHTML DTDs from the W3C. Then set up an XmlResolver and use it to expand any entities found in the document.

    You could use a regular expression to find/expand the entities, but that won't know anything about context (e.g., anything in a CDATA section shouldn't be expanded).

提交回复
热议问题