Filtering illegal XML characters in Java

后端 未结 7 1650
粉色の甜心
粉色の甜心 2020-12-30 09:19

XML spec defines a subset of Unicode characters which are allowed in XML documents: http://www.w3.org/TR/REC-xml/#charsets.

How do I filter out these characters from

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-30 09:33

    Use either escapeXml10 or escapeXml11. These functions escape characters like ", &, ', <, > and a few more but also filter invalid characters.

    For those who don't want to filter invalid characters but escape them with a different escaping system, look at my answer here https://stackoverflow.com/a/59475093/3882565.

提交回复
热议问题